From all the docs I've found, there is no mention of syntax like offset[var+offset2]
in Intel x86 syntax but GCC with the following flags
gcc -S hello.c -o - -masm=intel
for this program
#include<stdio.h>int main(){ char c = 'h'; putchar(c); return 0;}
produces
.file "hello.c" .intel_syntax noprefix .text .globl main .type main, @functionmain:.LFB0: .cfi_startproc push rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 mov rbp, rsp .cfi_def_cfa_register 6 sub rsp, 16 mov BYTE PTR -1[rbp], 104 movsx eax, BYTE PTR -1[rbp] mov edi, eax call putchar@PLT mov eax, 0 leave .cfi_def_cfa 7, 8 ret .cfi_endproc.LFE0: .size main, .-main .ident "GCC: (Arch Linux 9.3.0-1) 9.3.0" .section .note.GNU-stack,"",@progbits
I'd like to highlight the line mov BYTE PTR -1[rbp], 104
where offset -1
appears outside the square brackets. TBH, I'm just guessing that it is an offset, can anyone direct me to a proper documentation highlighting this ?
Here is a similar question: Squared Brackets in x86 asm from IDA where a comment does mention that it is an offset but I'd really like a proper documentation reference.