2

I am translating musl's x86_64 sigsetjmp into intel syntax but cannot figure out what the following two lines of assembly are doing:

mov %rbx,72+8(%rdi)
...
mov 72+8(%rbx),%rbx

My guess is it is getting the value at 8(%rdi) and adding 72 to it. But I can't find a way to do that in intel syntax so not sure. I haven't found anything online that explains what this syntax is doing.

snowytrees
  • 21
  • 2
  • 2
    Nope. the same as writing `mov %rbx, 80(%rdi)` which is mov value in RBX to memory address [80+rdi] . Same as `mov [rdi+72+8],rbx` or `mov [rdi+80],rbx`. The reverse for the last line. – Michael Petch Jan 14 '23 at 02:59
  • I should clarify I guess. 80 (or 72+8) is added to the value in RDI and that is treated as the memory address. – Michael Petch Jan 14 '23 at 03:48
  • 2
    Basically a duplicate of [A couple of questions about \[base + index\*scale + disp\] and AT&T disp(base, index, scale)](https://stackoverflow.com/q/27936196) which includes an `foo-0x10(,%edx,2)` addressing-mode example. But a duplicate specifically about constant expressions as assemble-time constants might be better, and the fact that you can't load-and-add except with a memory-source `add` instruction like `mov $72, %ebx` / `add 8(%rdi), %rbx`. That seems to be the crux of the confusion here. – Peter Cordes Jan 14 '23 at 05:11
  • [Converting \[symbol + constant\] Intel syntax addressing mode to AT&T syntax?](https://stackoverflow.com/q/61090374) is related. – Peter Cordes Jan 14 '23 at 05:13
  • That answers my questions thanks! I overlooked that because it was talking about in relation to a `foo` symbol rather than a constant. I knew you couldn't move into a constant which was making me even more confused :) – snowytrees Jan 14 '23 at 07:09
  • Technically a symbol is just a constant memory address that the assembler is managing for you. – puppydrum64 Jan 18 '23 at 11:56

0 Answers0