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
1 answer

Creating new instruction (double operand)

I've been reading a book and i got stuck in this: They showed me this chart: I put this values by myself (does it make sense to you?): PC (program counter) = 16 bits TAR (temporary address register) = 16 bits MAR (memory address register) = 16…
user8007135
0
votes
0 answers

Assembly mov instruction is not recognized

I was taught that I could use this instruction: movl (arr,%r8,4),%eax in case I wanted to do: %eax=Mem[arr+4*%r8] However this command doesn't seem to be recognized at all and I am getting an error: Error: Found ',', expected ')' Error: junk…
EL_9
  • 404
  • 2
  • 10
0
votes
0 answers

How do I copy from memory into register by using a label and register as offset?

I'm trying to create a print_hex function that converts a hex value in register bx into a character array and I am struggling to realize why is nasm is telling me that I have an invalid effective address. My print_hex function looks like this:…
G.P
  • 1
0
votes
2 answers

Converting [symbol + constant] Intel syntax addressing mode to AT&T syntax?

I just cant figure out how to add an offset to my destination when moving a value, specifically in Intel syntax I have: MOV [gdtr + 2], EAX and for AT&T syntax I have tried converting it to: movl %eax, gdtr(2,1) which gives an error when…
drewpel
  • 465
  • 1
  • 3
  • 16
0
votes
1 answer

Assembly - Moving through a register/array with an offset of 5

Quick question. This code will not compile: mov eax, dword [rbx+rsi*5] I don't expect it to, with the explaination that mov and multiplication are two different CPU operations. The only reason it can be achieved is through bit-shifting. However,…
zapshe
  • 228
  • 1
  • 8
0
votes
1 answer

How is it being specified which segment register should be used (x86)

Here's a function: void func(char *ptr) { *ptr = 42; } Here's an output (cut) of gcc -S function.c: func: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp …
0
votes
1 answer

Assembly - Do implicit calculations change the opcode?

When I have an operation like mov eax, [input+10]: Does it have a different opcode than this operation: mov eax, [input] (considering that input now has the value of former input+10)?
MenNotAtWork
  • 145
  • 2
  • 8
0
votes
1 answer

Segment and offset uses

Early on, memory size was little (64 KiB) and it just needed a 16-bit register to address it. But later memory with 1 MiB came. So we need bigger address registers. But in 8086 CPUs instead they used another register and called it offset. So with…
user11801832
0
votes
1 answer

difference between memory at and ptr in assembly

Back at it with another assembly question. I am having a hard time seeing what is the difference between square brackets and ptr in assembly. mov dword ptr eax, 1234 ; this should write 1234 to the memory address stored at eax right? mov dword ptr…
geo10
  • 366
  • 2
  • 11
0
votes
0 answers

What does means such offsets [rax+r14d-15] [rdi*1+r14]

Became to learn asm and can not understand what mean means those offsets, in default [EBX+000008c] or same it`s clear but not when register plus or minus other register put some examples please
user199588
  • 539
  • 2
  • 6
  • 21
0
votes
2 answers

Assembly pointer, absolute address

I'm new and I'm practicing computer science alone as a passion. In assembly a base pointer is used that allows me to refer to a specific memory location by subtracting a certain offset from the base pointer. What is obtained is the absolute address.…
Tony92
  • 95
  • 1
  • 6
0
votes
1 answer

How i can access a variable data using a variable value in adress like [ var_+[second_byte] ]?

I got this code: BITS 16 data: bytemap: db 0x0, 0x1, 0x4; pixel_x: db 2; to return the 0x4 value main: ; code... mov al, [bytemap+[pixel_x]]; i need that byte in al register ; more code... jmp main; but nasm returns…
0
votes
0 answers

What is the addressing mode used in MOV EDX, [EBX + 8*EAX + 4]?

MOV EDX, [EBX + 8*EAX + 4] I've been unable to find the name in the documentation for the addressing mode that allows for the base pointer, counter, multiple and displacement. I'd like to find out exactly how this works and what are the…
Listerone
  • 1,381
  • 1
  • 11
  • 25
0
votes
1 answer

What does movsbq and this add line do?

I am trying to figure out what these lines of code do movsbq (%rbx),%rcx and add (%rdx,%rcx,4),%eax
0
votes
1 answer

what does movzwl 0x402ac0(%rax,%rax,1),%eax and movslq 0x402740(,%rsi,4),%rdx mean in x86-64 assembly?

I am working on some projects about assembly and I encountered following commands: lea (%rsi,%rsi,4),%rax lea (%r9,%rax,2),%rsi lea (%r8,%rdx,4),%rax movzwl 0x402ac0(%rax,%rax,1),%eax movslq 0x402740(,%rsi,4),%rdx what's the meaning of…
kyandy
  • 21
  • 6