有关新 AVR 指令 LAC、LAS、LAT 和 XCH 的更多详细信息

发布于 2024-12-27 16:03:24 字数 329 浏览 2 评论 0 原文

看一下AVR指令集,2010年新增了4条指令

LAC load and clear
LAS load and set
LAT load and toggle
XCH load and exchange
  1. 有谁知道哪些芯片有这些指令

  2. 哪些工具支持这些指令

  3. 有关他们所做的事情的更多信息

    (Z) <- Rd v (Z)、Rd <- (Z)

这是否意味着 Rd 和 (Z) 获得相同的值,或者 Rd 是否获得 Z 所指向的值的预修改值?

Looking at the AVR instruction set there are four instructions added in 2010

LAC load and clear
LAS load and set
LAT load and toggle
XCH load and exchange
  1. Does anyone know what chips have these instructions

  2. What tools support these instructions

  3. More information on what they do

    (Z) <- Rd v (Z), Rd <- (Z)

does that imply that Rd and (Z) get the same value or does Rd get the pre-modified value of what was pointed to by Z?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故乡的云 2025-01-03 16:03:24

这些可能不存在于当前(截至最初问题)芯片中,但都有一个共同的主题 - 原子内存操作。它们的目的通常是用于线程之间的同步,并且将它们包含在指令集级别可能表明 Atmel 正计划推出多核 AVR 芯片。由于现在已经指定了它们,工具供应商已经可以将它们添加到汇编器中,但在芯片拥有指令之前,他们不会对此大做文章。 (编辑:事实证明,另一个核心是 USB 外设,而不是 CPU。感谢 avakar 提供的信息。)

这种行为,正如我从 Atmel AVR 8 位指令集手册

LAC - 加载和清除,将内存内容 *Z 加载到寄存器中路同时同时清除 *Z 中 Rd 中设置的位。

LAS - 加载和设置同时设置内存位置中已在寄存器中设置的位,并使用内存位置的先前内容加载寄存器。例如,对于单位互斥体非常有用。

LAT - 加载和切换;与 LAS 类似,但它不是按位或,而是使用按位异或,从而切换位。

XCH——交易所;只是交换内存和寄存器内容。

所有这些都是 RAM 访问指令(07/2014 参考状态,它们需要两个周期),它们组合了操作,因此它们还可以使需要 RAM 的代码比当前更快。

These are probably not around in current (as of initial question) chips, but all have a common theme - atomic memory operations. Their purpose is typically for synchronisation between threads, and their inclusion at an instruction set level probably indicates that Atmel are planning to launch a multi-core AVR chip. Since they're specified now tool vendors can add them to assemblers already, but they won't make a big deal of that until chips have the instructions. (Edit: As it turns out, the other core is the USB peripheral, not a CPU. Thanks to avakar for that information.)

The behaviour, as I read it from the Atmel AVR 8-bit Instruction Set Manual:

LAC - Load and Clear, loads memory contents *Z into register Rd while simultaneously clearing bits in *Z that were set in Rd.

LAS - Load And Set simultaneously sets bits in a memory location that were set in a register, and loads the register with the prior contents of the memory location. Very useful for single-bit mutexes, for instance.

LAT - Load And Toggle; like LAS, but instead of bitwise or, it uses bitwise xor, thus toggling bits.

XCH - Exchange; simply exchanges memory and register contents.

All of them are RAM access instructions (07/2014 reference states they take two cycles), which combine operations so they could also make code that needs RAM faster than it currently is.

半透明的墙 2025-01-03 16:03:24

需要强调的小但重要的细节:LAS、LAC 和 LAT 指令仅在 Z 指向“真实”SRAM 时起作用。这不是(内存映射)寄存器等。因此,事实上,这些对于您自己的(操作系统)数据或 XMega USB 模块很有用,没有其他外设和模块。

遗憾的是(例如,因为它对于操作 PMIC.CTRL 标志非常方便),但它确实不起作用。已测试。当应用于内存映射寄存器时,LAS、LAC 和 LAT 看起来与 XCH 具有相同的效果(Rd 和 (Z) 之间交换,但没有位旋转)。

Small but important detail to emphasize: the LAS, LAC and LAT instructions work when Z points to "real" SRAM only. That is not (memory mapped) registers etc. So, in fact, these are useful either for your own (OS) data or XMega USB module, no other peripherals and modules.

It is a pity (as it would be really handy for manipulating PMIC.CTRL flags for example), but it really does not work. Tested. It looks like that LAS, LAC and LAT has the same effect as XCH (exchange between Rd and (Z) but no bit twiddling) when applied on memory mapped registers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文