I have the following snippet which at the end of it I need to specify what is the value inside %rbx
.
.global _start
.section .data
array: .long 0xf415, 0xf3561768, 0x8200f645
a: .short 1
b: .quad 0x670081b521c
.section .bss
.lcomm stam, 4
.section .text
_start:
xor %rcx, %rcx
xor %rax, %rax
xor %esi, %esi
lea array, %rbx
Since I am a total beginner in assembly, I want to try and break down the code line by line to test my understanding of it and I would love it if you could correct my mistakes.
.global _start
states that our program starts to run from label _start
.
.section .data
states that we enter an initialization of "variables" section.
array: .long 0xf415, 0xf3561768, 0x8200f645
initialize an array of longs with 3 values 0xf415, 0xf3561768, 0x8200f645
a: .short 1
initializes variable a with one bit value of 1
.
b: .quad 0x670081b521c
initializes variable b with 64 bit value of 0x670081b521c
.section .bss
declaration of other variables without initialization
.lcomm stam, 4
declares variable stam
and stores 4 bit for it.
.section .text
declaring a read-only section.
_start:
xor %rcx, %rcx
xor %rax, %rax
xor %esi, %esi
starting the main program and initializes to 0 registers rcx, rax, esi
.
lea array, %rbx
- I am having a hard time understanding how is the effective address is calculated here since array
has 3 values (if my assumptions were right)
EDIT:
Does lea array, %rbx
"translate to" %rbx = 0xf415 + (0xf3561768 * 0x8200f645)
?
EDIT:
If it is given that the start of the data sections in memory is 0x601038
, does it mean that lea array, %rbx
"translates to" %rbx = 0x601038
?
Not sure it is relevant in this case but I am working on a processor that uses little-endian.