Hi. This is my first post. I took an example to display register from the internet and changed it to 64-bit (linux). But the code displays garbage. This prog use 16-byte char array inside the function and use it for stosb instruction to display register string. Can u help me point out where I did wrong?
mov r10,0bcfefab4323c5677h
push r10
call display_register
xor rdi,rdi ;exit
mov rax,60
syscall
display_register:
push rbp
mov rbp,rsp
sub rsp,16 ;local space for string
cld
lea rdi,[rbp-16] ;address of string for stosb
mov r10,[rbp+16] ;first argument
xor rax,rax
mov rcx,16
start:
shld rax,r10,4
add al,30h
cmp al,39h
jbe normal
add al,7
normal:
stosb
dec rcx
test rcx,rcx
jz disp_string
rol r10,4
jmp start
disp_string:
mov edx,16 ;size
mov edi,1 ;stdout
mov eax,1 ;sys_write
lea rsi,[rbp-16] ;address of string
syscall
add rsp,16
mov rsp,rbp
pop rbp
ret