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
0
votes
0 answers

How to calculate x86 code mov offset (RIP-relative machine code)?

How to calculate x86 code mov offset(machine code)? please also give an example !! I want to input full address. Anyway make it possible? Address: 7FFB4AB12910, I want something like this: 48 8B 0D 352047A4B4FF07 7FFB4A0A0003 - 48 8B 0D 0629A700…
0
votes
0 answers

Is there a way to use a variable offset in assembly?

Trying to shortcut the main part of a palindrome checking program see below: li $t9, $t6($t5) bne $t9, $t7($t5), no1 This throws a syntax error, is there not a way to use a variable as an offset in assembly? Using PLP software tool 5.2
0
votes
0 answers

Calculate Physical Address at which AL will get stored in MOV AL,5[SI][BP]

In 8086 microprocessor: MOV AL,5[SI][BP] here's the effective address according to how i calculate: SS*10 + SI + BP + 5 as BP is offset register for stack segment. But, SI is a offset register for data segment. So, I think base address of DS should…
Isac
  • 314
  • 2
  • 15
0
votes
0 answers

C code to Assembly meaning of DWORD PTR a[rip]

I had an assigment to translate a C code to Assembly intel syntax x86. int a; void fg(){ a=2; } int main(){ fg(); return a; } The result was this: fg: push rbp mov rbp, rsp mov DWORD PTR a[rip], 2 …
0
votes
0 answers

x86 Assembly (AT&T): How to use advanced indexing to set a specific section in memory

I am trying to set the second byte of the content marked by the label variable to the content of the EAX register through advanced indexing. When I execute the code below: movl %eax, 2(variable) I receive the following error: Error: junk…
Adam Lee
  • 436
  • 1
  • 14
  • 49
0
votes
1 answer

x86 Assembly (Advanced Indexing Mode): How do I access memory at a variable amount ahead of a start address?

I am trying to read a section of memory, byte by byte, starting from the memory address stored in the EAX register. I push the current byte to the EBX register. However, when I execute the following line of code (advanced indexing mode): movb…
Adam Lee
  • 436
  • 1
  • 14
  • 49
0
votes
1 answer

How to use two registers for addressing?

I have problems executing the code below unique proc invoke lstrlen, esi cmp eax, 1 jle quit mov ebx, 0; previous iterator mov edx, 0; next iterator dec eax mov ecx, eax inc eax next: inc edx cmp…
alexander.sivak
  • 4,352
  • 3
  • 18
  • 27
0
votes
1 answer

x86-64 accessing element of array

Hi I am a beginner in assembly language, is there a difference between movl (%rdi,%r12), %r10d and movl (%rdi,%r12,4), %r10d? I tried both of them and they both seem to do the same job-- saving the element of %rdi at %r12 position to %r10d. Is the…
M. Chen
  • 203
  • 1
  • 6
0
votes
1 answer

What is the "-4" for in assembler: movl $1, -4(%rbp)

int x=1; int y=2; int z=3; turns into movl $1, -4(%rbp) movl $2, -8(%rbp) movl $3, -12(%rbp) What is the -4,-8,-12 for ? Why is it going by 4's? 4 bytes = 32 bits?
JackOfAll
  • 377
  • 1
  • 3
  • 13
0
votes
0 answers

How to do a reverse offset/index in x86

I am trying to do a negative offset for memory addressing. This is to convert a number to a string and make sure that it doesn't print in reverse order since x86 is little endian. Here is what I'm trying to do: # (b) move the asci number to…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
0
votes
0 answers

Possible to access an array with index at memory address?

I am currently accessing an array like this: ARRAY: .long 1,2,3,4 # put index in register ebx mov $4, %ebx # put nums value in eax mov nums(,%ebx,4), %eax Is it possible to, instead of using a register for the array to use an address on the…
David542
  • 104,438
  • 178
  • 489
  • 842
0
votes
0 answers

Two ways of using offsets in memory addressing

For accessing arrays, I have the seen the following two notations used quite often: # Addressing in the general form of: # address_or_offset(%base_or_offset, %index, scale) # (1) using a label, which resolves to an address movzwq myarray(, %rdi,…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
0
votes
0 answers

Referencing a variable directly vs relative to %rip

I've used the following two different approaches to referencing a variable in assembly. Using the variable itself: # Move a variable, directly referencing it rather than relative to %rip movzbq my_var, %r14 leaq my_var, %r15 And then…
samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
0
votes
0 answers

Doing direct addressing mode in asm

I am practicing the various data accessing modes in assembly. Here is what I have so far: # Practicing the various Data Accessing methods .globl main main: # Immediate mode mov $7, %rbx # Register addressing mode mov %rbx, …
David542
  • 104,438
  • 178
  • 489
  • 842
0
votes
0 answers

Assembly language loading SI with BX saying invalid use

In my masm project there is one line of code as given below LDS SI,[SS:BX] When i try to execute above line of code then MASM gives following error: ERROR: invalid use of register Please guide me.
godmahakal
  • 57
  • 3