I know that the suggestion I'm going to say is probably the best way to become very unpopular in StackOverflow very quickly. Anyway, Iโll say: why doesnโt it work (completely)?
I tried to figure out what the lea / leal instruction does . As I understand it, lea / leal detects the memory address of the first operand and writes this address to the second operand (which may be a register or so).
This part seems to work. When I run the program below, it says:
The memory address of var is 134518204.
However, right after that, he says something like "memory access error." pushl (% eax) is clearly not working. Why not?
.data
var: .long 42
str1: .string "The memory address of var is %d.\n"
str2: .string "At this memory address we find var value: %d.\n"
.text
.global main
main:
leal var, %eax
pushl %eax
pushl $str1
call printf
pushl (%eax)
pushl $str2
call printf
movl $1, %eax
int $0x80
I'm not even sure that I am right what lea / leal does. Help is appreciated .;)