att

assembly leal and movl difference [duplicate]

折月煮酒 提交于 2019-11-27 06:23:41
问题 This question already has answers here : Using LEA on values that aren't addresses / pointers? (3 answers) Closed 2 years ago . leal(%eax,%ecx,4), %edx as I was reading from my computer systems book, if there`s premises that $eax contains x value and %ecx contains y, then the above means, x+4y putting into %edx. then if it is movl(%eax,%ecx,4), %edx , then isn`t the same one with leal expression above? As I know, leal creates address that can be referenced,not referencing by itself like movl,

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 is the order of source operands in AT&T syntax compared to Intel syntax?

Deadly 提交于 2019-11-27 02:16:12
The Intel ISA reference documentation for this instruction is clear: VPBLENDVB xmm1, xmm2, xmm3/m128, xmm4 Select byte values from xmm2 and xmm3/m128 using mask bits in the specified mask register, xmm4 , and store the values into xmm1 . xmm1 is the destination, xmm2/3/4 are source operands So what does this become using AT&T syntax? We know that the destination register must be last, but what is the order of source operands? vpblendvb $xmm2, $xmm3, $xmm4, $xmm1 or vpblendvb $xmm4, $xmm3, $xmm2, $xmm1 or something else? Assembling (note GAS uses % instead of $ to denote registers) the

What is the meaning of MOV (%r11,%r12,1), %edx?

▼魔方 西西 提交于 2019-11-27 02:11:41
What does this instruction do? mov (%r11,%r12,1), %edx Look here . It says In the AT&T Syntax, memory is referenced in the following way, segment-override:signed-offset(base,index,scale) Down on the page there are some examples. I find this the best: GAS memory operand NASM memory operand ------------------ ------------------- (%ecx,%ebx,2) [ecx+ebx*2] mov source, destination in AT&T syntax copies the value from source to destination. Also consider the size of edx. How many bytes (4) do you think mov will copy ? mov (%r11,%r12,1), %edx this instruction is use to calculate the address (indexed

The point of test %eax %eax [duplicate]

ε祈祈猫儿з 提交于 2019-11-26 23:49:31
问题 Possible Duplicate: x86 Assembly - ‘testl’ eax against eax? I'm very very new to assembly language programming, and I'm currently trying to read the assembly language generated from a binary. I've run across test %eax,%eax or test %rdi, %rdi , etc. etc. I'm very confused as to what this does. Isn't the values in %eax, %eax the same? What is it testing? I read somewhere that it is doing the AND operation.....but since they are the same value, wouldn't it just return %eax ? The following is

Unable to move variables in .data to registers with Mac x86 Assembly

回眸只為那壹抹淺笑 提交于 2019-11-26 22:09:06
问题 I have written a small piece of assembly with AT&T syntax and have currently declared three variables in the .data section. However, when I attempt to move any of those variables to a register, such as %eax , an error from gcc is raised. The code and error message is below: .data x:.int 14 y:.int 4 str: .string "some string\n" .globl _main _main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl x, %eax; #attempting to move the value of x to %eax; leave ret The error raised is: call_function.s

What does a comma in a parenthesis mean in the AT&T syntax for x86 assembly?

大兔子大兔子 提交于 2019-11-26 22:07:19
问题 What does (register1, register2, 4) mean in AT&T assembly? For example: cmp %eax, (%esi, %ebx, 4) 回答1: The complete AT&T base/index register syntax is: offset(base, index, multiplier) Your offset field is 0 , so you just have the (base, index, multiplier) part. In your case, you're comparing the contents of the eax register to the 32-bit value located at esi + (ebx * 4) . In the Intel syntax you might be more familiar with, this would be written as: cmp [ebx*4 + esi], eax 来源: https:/

What is the “.s” suffix in x86 instructions?

不问归期 提交于 2019-11-26 21:47:41
问题 When I disassemble the .text sections of some binaries using objdump (with both AT&T and Intel syntaxes), I sometimes see instructions with a .s suffix, for example: cmpb.s %bh,%ch , sbbl.s %edi,%edi , or adcb.s %bl,%dh . Does the .s suffix have a valid/useful meaning (perhaps not even as a suffix), or is this an artefact of disassembling some data / padding as if it was a sequence of instructions? Thank you. 回答1: To understand what the .s suffix means, you need to understand how x86

What does cltq do in assembly?

你。 提交于 2019-11-26 19:06:07
0x0000000000400553 <main+59>: mov -0x4(%rbp),%eax 0x0000000000400556 <main+62>: cltq 0x0000000000400558 <main+64>: shl $0x3,%rax 0x000000000040055c <main+68>: mov %rax,%rdx In fact my programe is as simple as : 5 int main(int argc, char *argv[]) { 6 int i = 0; 7 while(environ[i]) { 8 printf("%s\n", environ[i++]); 9 } 10 return 0; But the assembly output is pretty long: Dump of assembler code for function main: 0x0000000000400518 <main+0>: push %rbp 0x0000000000400519 <main+1>: mov %rsp,%rbp 0x000000000040051c <main+4>: sub $0x20,%rsp 0x0000000000400520 <main+8>: mov %edi,-0x14(%rbp)

CMP in x86 with parentheses and address

断了今生、忘了曾经 提交于 2019-11-26 18:35:15
问题 I have the following line in x86 Assembly language that I don't know what it does... cmp %eax,0x80498d4(,%ebx,4) I know it's comparing the two halves of the statement but I don't know what the address does in it and what the parentheses do either. Some clarification would be much appreciated! 回答1: In AT&T syntax this form represents OFFSET(BASE REGISTER, INDEX REGISTER, INDEX SCALE) so the address represented is the value of BASE REGISTER (if present) + INDEX * SCALE (if present) + OFFSET, so