intel-syntax

Questions about AT&T x86 Syntax design

爱⌒轻易说出口 提交于 2019-11-27 04:25:23
问题 Can anyone explain to me why every constant in AT&T syntax has a '$' in front of it? Why do all registers have a '%'? Is this just another attempt to get me to do a lot of lame typing? Also, am I the only one that finds: 16(%esp) really counterintuitive compared to [esp+16] ? I know it compiles to the same thing but why would anyone want to type a lot of '$' and '%'s without a need to? - Why did GNU choose this syntax as the default? Another thing, why is every instruction in at&t syntax

What does the dollar sign ($) mean in x86 assembly when calculating string lengths like “$ - label”? [duplicate]

徘徊边缘 提交于 2019-11-27 01:18:53
This question already has an answer here: How does $ work in NASM, exactly? 1 answer For example, if we were writing a simple hello world type program, the .data section might contain something like: section .data msg db 'Enter something: ' len equ $ - msg What does the $ in this example represent, and why does $ - msg equal the length of the string? It means the address of "here". In here "here" is the byte after the end of the msg string. Any assembler documentation will describe this. Read the documentation. In this case, the $ means the current address according to the assembler. $ - msg

How do GNU assembler x86 instruction suffixes like “.s” in “mov.s” work?

这一生的挚爱 提交于 2019-11-26 22:04:41
问题 GNU assembler appears to have some means of controlling the alternative forms of the opcode being emitted for some instructions. E.g. .intel_syntax noprefix mov eax, ecx mov.s eax, ecx Processing the above code with as test.s -o test.o && objdump -d test.o -M intel gives the following disassembly: 0: 89 c8 mov eax,ecx 2: 8b c1 mov eax,ecx We can see that .s suffix appears to switch 89 opcode to the 8b version (and appropriately change the ModRM byte). How does this syntax work in GAS? I can't

What does the dollar sign ($) mean in x86 assembly when calculating string lengths like “$ - label”? [duplicate]

故事扮演 提交于 2019-11-26 09:35:30
问题 This question already has an answer here: How does $ work in NASM, exactly? 1 answer For example, if we were writing a simple hello world type program, the .data section might contain something like: section .data msg db \'Enter something: \' len equ $ - msg What does the $ in this example represent, and why does $ - msg equal the length of the string? 回答1: It means the address of "here". In here "here" is the byte after the end of the msg string. Any assembler documentation will describe