Reputation:
I need to write an array of bytes but i don't get it, only [matrix + 0]
and [matrix + 1]
is written(what i mean, EAX should be equal to 0301070F
), what i am doing wrong?
This is my code:
%include "asm_io.inc"
segment .data
matrix times 4 db 0
segment .bss
segment .text
global asm_main
asm_main:
enter 0,0
pusha
mov eax, 0
mov dword [matrix + 3], 15
mov dword [matrix], 3
mov dword [matrix + 1], 1
mov dword [matrix + 2], 7
mov ah, [matrix]
mov al, [matrix + 1]
rol eax, 16
mov ah, [matrix + 2]
mov al, [matrix + 3]
dump_regs 1
popa
mov eax, 0
leave
ret
and this is the output of dump_regs 1
:
Register Dump # 1
EAX = 03010000 EBX = B774FFF4 ECX = BFF7C924 EDX = BFF7C8B4
ESI = 00000000 EDI = 00000000 EBP = BFF7C868 ESP = BFF7C848
EIP = 080484D8 FLAGS = 0282 SF
The caller is a simple C
program:
int main() {
int ret_status;
ret_status = asm_main();
return ret_status;
}
Edited: I found something wrong here, if i execute this code, all is working:
mov dword [matrix], 3
mov dword [matrix + 1], 1
mov dword [matrix + 2], 7
mov dword [matrix + 3], 15
but if i execute this, doesn't work:
mov dword [matrix + 3], 15
mov dword [matrix], 3
mov dword [matrix + 1], 1
mov dword [matrix + 2], 7
Why?
Upvotes: 3
Views: 655
Reputation: 94279
It's been some time, but shouldn't
mov dword [matrix], 3
rather be something like
mov byte [matrix], 3
to avoid that the constant 3
is treated as a 32bit value?
Upvotes: 3