att

How to determine if the registers are loaded right to left or vice versa

青春壹個敷衍的年華 提交于 2019-11-28 14:16:14
When reviewing gdb output and looking at the assembly calls, usually I can find a command using hard-coded values to determine whether the registers are being loaded right to left or vice versa. Usually something like the following: sub rsp, 16 or sub 16, rsp But other times, no values like above are visible. All I see are calls like the following : (gdb) disassemble Dump of assembler code for function main: 0x0000000100000f54 <main+4>: mov $rdi,%r15 0x0000000100000f59 <main+9>: mov $rsi,%r14 0x0000000100000f60 <main+16>: mov $rdx,%r13 0x0000000100000f67 <main+23>: mov $ecx,$r12d End of

x86 instruction meaning [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-11-28 14:11:44
This question already has an answer here: What is the meaning of MOV (%r11,%r12,1), %edx? 2 answers How does “mov (%ebx,%eax,4),%eax” work? [duplicate] 1 answer I'm running through some code right now on gdb and I have no clue what these two instructions actually do. If anyone could help me out, I'd really appreciate it. add -0x2c(%ebp, %ebx, 4), %eax cmp %eax, -0x28(%ebp, %ebx, 4) x86 assembly is usually much easier to understand when you write it in Intel syntax instead of AT&T syntax. In Intel syntax it would be: add eax,[ebp+4*ebx-0x2C] cmp [ebp+4*ebx-0x28],eax The first instruction ( add

CMP in x86 with parentheses and address

不羁岁月 提交于 2019-11-28 14:04:21
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! 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 EBX*4 + 0x80498d4 in your case. That is AT&T syntax: cmp %eax,0x80498d4(,%ebx,4) The equivalent in Intel

assembly leal and movl difference [duplicate]

让人想犯罪 __ 提交于 2019-11-28 11:40:59
This question already has an answer here: Using LEA on values that aren't addresses / pointers? 3 answers 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, but when I saw leal(%eax,%ecx,4), %edx equals putting x+4y into edx register, then doesn t it mean that it 'referenced' %eax

A couple of questions about [base + index*scale + disp]

谁都会走 提交于 2019-11-28 10:20:57
The general form for memory addressing in Intel and AT&T Syntax is the following: [base + index*scale + disp] disp(base, index, scale) My questions are the following: Can base and index be any register? What values can scale take, is it 1, 2, 4 and 8 (with 1 being the default)? Are index and disp interchangeable (with the only difference being that index is a register while disp is an immediate value)? Michael This is described in Intel's manual: 3.7.5 Specifying an Offset The offset part of a memory address can be specified directly as a static value (called a displacement) or through an

How to load address of function or label into register in GNU Assembler

别说谁变了你拦得住时间么 提交于 2019-11-28 08:58:24
问题 I am trying to load the address of 'main' into a register (R10) in the GNU Assembler. I am unable to. Here I what I have and the error message I receive. main: lea main, %r10 I also tried the following syntax (this time using mov) main: movq $main, %r10 With both of the above I get the following error: /usr/bin/ld: /tmp/ccxZ8pWr.o: relocation R_X86_64_32S against symbol `main' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable

What does the MOVZBL instruction do in IA-32 AT&T syntax?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 08:54:22
What exactly the instruction movzbl 0x01(%eax,%ecx),%eax does? Igor Skochinsky AT&T syntax splits the movzx Intel instruction mnemonic into different mnemonics for different source sizes ( movzb vs. movzw ). In Intel syntax, it's: movzx eax, byte ptr [eax+ecx+1] i.e. load a byte from memory at eax+ecx+1 and zero-extend to full register. BTW, most GNU tools now have a switch or a config option to prefer Intel syntax. (Such as objdump -Mintel or gcc -S -masm=intel , although the latter affects the syntax used when compiling inline-asm). I would certainly recommend to look into it, if you don't

The point of test %eax %eax [duplicate]

眉间皱痕 提交于 2019-11-28 02:48:45
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 just one instance where I found this usage: 400e6e: 85 c0 test %eax,%eax 400e70: 74 05 je 400e77 <phase_1

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

拥有回忆 提交于 2019-11-28 02:09:45
What does (register1, register2, 4) mean in AT&T assembly? For example: cmp %eax, (%esi, %ebx, 4) Carl Norum 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://stackoverflow.com/questions/18650093/what-does-a-comma-in-a-parenthesis-mean-in-the-att-syntax-for-x86

Calculating padding length with GAS AT&T directives for a boot sector?

♀尐吖头ヾ 提交于 2019-11-28 02:03:36
So I want to add padding in the bootsector. Let's say, there is currently just an endless loop in there: jmp . . The sector needs to be 512 bytes long. Also, the magic num 0xaa55 is needed which is added at the end. jmp . .skip 508, 0 .word 0xaa55 But what if I want to print something but don't want to count all the bytes to pad it into the right size? In Intel/NASM syntax would it be: ; print something times 510-($-$$) db 0 dw 0xaa55 But in AT&T syntax? Well a loop ( .rept ) doesn't work here because . doesn't give an absolute value which is needed here. We have the same problem with .skip /