addressing-mode

Assembler jump in Protected Mode with GDT

不羁岁月 提交于 2019-11-30 05:03:56
I am currently playing around with x86 Assember in order to sharpen my low-level programming skills. Currently, I am facing a little problem with the addressing scheme in 32-Bit Protected Mode. The situation is the following: I have a Program loaded at 0x7e0 which switches the CPU to Protected Mode and jumps to the according label in the code: [...] code to switch CPU in Protected Mode [...] jmp ProtectedMode [...] bits 32 ProtectedMode: .halt: hlt jmp .halt This works absolutely fine so far. The "jmp ProtectedMode" works without a explicit far jump to clear the prefetch queue - since this

Meaning of (%eax) in AT&T syntax?

非 Y 不嫁゛ 提交于 2019-11-30 03:21:19
You'll have to excuse me, I'm brand new to x86 assembly, and assembly in general. So my question is, I have something like: addl %edx,(%eax) %eax is a register which holds a pointer to some integer. Let's call it xp Does this mean that it's saying: *xp = *xp + %edx ? ( %edx is an integer) I'm just confused where addl will store the result. If %eax is a pointer to an int, then (%eax) should be the actual value of that int. So would addl store the result of %edx+(%eax) in *xp ? I would really love for someone to explain this to me! I really appreciate any help! Jay Conrod Yes, this instruction

Assembler jump in Protected Mode with GDT

a 夏天 提交于 2019-11-29 02:50:12
问题 I am currently playing around with x86 Assember in order to sharpen my low-level programming skills. Currently, I am facing a little problem with the addressing scheme in 32-Bit Protected Mode. The situation is the following: I have a Program loaded at 0x7e0 which switches the CPU to Protected Mode and jumps to the according label in the code: [...] code to switch CPU in Protected Mode [...] jmp ProtectedMode [...] bits 32 ProtectedMode: .halt: hlt jmp .halt This works absolutely fine so far.

Why does this MOVSS instruction use RIP-relative addressing? [duplicate]

主宰稳场 提交于 2019-11-28 14:16:09
This question already has an answer here: Why is the address of static variables relative to the Instruction Pointer? 1 answer I found the following assembly code in disassembler (floating point logic c++). 842: movss 0x21a(%rip),%xmm0 I understand that when process rip will allways be 842 and this 0x21a(%rip) will be const. It seems a little odd to use this register. I want to know is there any advantage of using rip relative address, instead other addressing. RIP is the instruction pointer register, which means that it contains the address of the instruction immediately following the current

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

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

lea assembly instruction

断了今生、忘了曾经 提交于 2019-11-28 00:34:10
问题 I Just want to make sure I am reading this right: movl 12(%ebp), %edx leal (%edx, %edx, 4), %eax I read the first line as: edx = [epb + 12] , and the second line as: eax = edx + edx*4 Can anybody clarify? Also, what if I had the following two lines: leal (%edx, %edx, 4), %eax leal (%edx, %edx, 2), %eax Once the second line is executed, would the eax register be overwritten? And the eax = edx + edx*4 is multiplying the address by 4? Or the contents of the address by 4? 回答1: You're right. 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

Addressing Modes in Assembly Language (IA-32 NASM)

筅森魡賤 提交于 2019-11-27 01:46:14
As the web-resources on this is sparse, I will, for the benefit of future searches, begin by listing the address modes for IA-32 Assembly Language (NASM) and then follow up with a quick question. Register addressing mov eax, ebx: Copies what is in ebx into eax mov esi, var: Copies address of var (say 0x0040120e) into esi Immediate addressing (second operand is an immediate constant) mov bx, 20: 16-bit register bx gets the actual value 20 Direct memory addressing (directly loads from memory through a specified address) mov ax, [1000h]: loads a 2-byte object from the byte at address 4096 (0x1000