Questions tagged [addressing-mode]

An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere.

From Wikipedia (Addressing mode):

Addressing modes are an aspect of the instruction set architecture in most central processing unit (CPU) designs. The various addressing modes that are defined in a given instruction set architecture define how machine language instructions in that architecture identify the operand (or operands) of each instruction. An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere.

296 questions
35
votes
1 answer

How to use RIP Relative Addressing in a 64-bit assembly program?

How do I use RIP Relative Addressing in a Linux assembly program for the AMD64 archtitecture? I am looking for a simple example (a Hello world program) that uses the AMD64 RIP relative adressing mode. For example the following 64-bit assembly…
Erik
  • 4,268
  • 5
  • 33
  • 49
32
votes
7 answers

What does an asterisk * before an address mean in x86-64 AT&T assembly?

What does the following line mean: ... 401147: ff 24 c5 80 26 40 00 jmpq *0x402680(,%rax,8) ... What does the asterisk in front of the memory address mean? Also, what does it mean when the memory access method is missing it's first register…
de1337ed
  • 3,113
  • 12
  • 37
  • 55
28
votes
1 answer

Understanding %rip register in intel assembly

Concerning the following small code, which was illustrated in another post about the size of structure and all the possibilities to align data correctly : struct { char Data1; short Data2; int Data3; char Data4; } x; unsigned fun ( void ) { …
user1773603
28
votes
1 answer

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

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:…
kodai
  • 3,080
  • 5
  • 32
  • 34
22
votes
1 answer

A couple of questions about [base + index*scale + disp] and AT&T disp(base, index, scale)

The general form for memory addressing in Intel and AT&T Syntax is the following: [base + index*scale + disp] # Intel, including GAS .intel_syntax noprefix disp(base, index, scale) # AT&T My questions are the following: Can base and…
user4344762
17
votes
1 answer

How to load address of function or label into register

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…
user11810714
17
votes
1 answer

How do RIP-relative variable references like "[RIP + _a]" in x86-64 GAS Intel-syntax work?

Consider the following variable reference in x64 Intel assembly, where the variable a is declared in the .data section: mov eax, dword ptr [rip + _a] I have trouble understanding how this variable reference works. Since a is a symbol corresponding…
Shuzheng
  • 11,288
  • 20
  • 88
  • 186
15
votes
2 answers

What do ds:si and es:di mean in assembly?

The movsb (move string, bytes) instruction fetches the byte at address ds:si, stores it at address es:di, and then increments or decrements the si and di registers by one. I know esi,si and edi,di registers, but not ds:si and es:di , what do…
new_perl
  • 7,345
  • 11
  • 42
  • 72
15
votes
2 answers

Addressing Modes in Assembly Language (IA-32 NASM)

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…
Magnus
  • 6,791
  • 8
  • 53
  • 84
13
votes
2 answers

The different addressing modes of CUDA textures

I am using a CUDA texture in border addressing mode (cudaAddressModeBorder). I am reading texture coordinates using tex2D(). When the texture coordinates fall outside the texture, tex2D() returns 0. How can I change this returned…
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
13
votes
2 answers

Assembly Segments in opcodes

I noticed that in Assembly segments are used in opcodes. Example: MOV DWORD PTR SS:[EBP-30],30 I think that "PTR SS:" is used to specify that EBP-30 comes from the stack? (SS: stack segment) Am I right or am I completely wrong? :) And, could you…
user1365914
  • 858
  • 2
  • 18
  • 32
12
votes
2 answers

Assembler jump in Protected Mode with GDT

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…
Sebastian B.
  • 287
  • 4
  • 19
12
votes
4 answers

What does the bracket in `movl (%eax), %eax` mean?

I have googled enough but could not figure out what the bracket () means. Also, I see some syntax as movl 8(%ebp), %eax Could some someone suggest me some good reference? I have not been able to find any in the top 20 results from Google.
Lord Loh.
  • 2,437
  • 7
  • 39
  • 64
12
votes
2 answers

Referencing the contents of a memory location. (x86 addressing modes)

I have a memory location that contains a character that I want to compare with another character (and it's not at the top of the stack so I can't just pop it). How do I reference the contents of a memory location so I can compare it? Basically how…
DrakeJacks
  • 187
  • 1
  • 2
  • 8
11
votes
2 answers

lea assembly instruction

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…
Chris Dargis
  • 5,891
  • 4
  • 39
  • 63
1
2 3
19 20