-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrax2hex.asm
More file actions
63 lines (54 loc) · 1.01 KB
/
rax2hex.asm
File metadata and controls
63 lines (54 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
; you can find more there :
;http://cogsandlevers.blogspot.fr/2013/01/printing-registers-value-in-hex.html
; mostly adapted this code to 64bit version
section .data
hex_chars db "0123456789ABCDEF"; hexchar for pretty printing
section .text
global _start
_print_nibble:
push rsi
push rax
push rdi
push rdx
mov rsi,hex_chars
add rsi,rax
mov rax,1
mov rdi,1
mov rdx,1
syscall
pop rdx
pop rdi
pop rax
pop rsi
ret
_print_al:
push rbx
mov bl,al
shr al,4
call _print_nibble
mov al,bl
and al, 0xf
call _print_nibble
pop rbx
ret
_print_rax:
mov rcx,8
_next_byte:
push rax
push rcx
dec rcx
shl rcx,3
shr rax, cl
and rax,0xFF
call _print_al
pop rcx
pop rax
dec rcx
jnz _next_byte
ret
_start:
mov rax, 0xb000b135b000b135 ; the value to print
call _print_rax ; print them to screen
mov rax,60
mov rdi, 0
syscall