-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathint2string.asm
More file actions
51 lines (45 loc) · 2.25 KB
/
int2string.asm
File metadata and controls
51 lines (45 loc) · 2.25 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
;//////////////////////////////////////////////////////////////////////////////////////////////////
;// [ INT_2_STR ]
;//////////////////////////////////////////////////////////////////////////////////////////////////
INT_2_STR: push rbp ; create the stack frame
mov rbp, rsp
push r12
push r11
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
;/////////////////////////////////////////////////////////////////
mov r11, STRBUFFER1
add r11, 0xFF
xor r12, r12
;//////////////////////////////////////////////////////////////
INT_2_LOOP: dec r11
mov rdx, 0x00 ; reminder from division
mov rbx, 0x0A ; base
div rbx ; rax = rax / 10
add rdx, 0x30 ; add 48
mov byte [r11], dl
inc r12 ; go next
cmp rax, 0x00 ; check factor with 0
jne INT_2_LOOP ; loop again
;//////////////////////////////////////////////////////////////
mov rdi, STDOUT
mov rsi, r11 ; pString
mov rdx, r12 ; cString
mov rax, SYS_WRITE
syscall
;/////////////////////////////////////////////////////////////////
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
pop r11
pop r12
mov rsp, rbp ; destroy the stack frame
pop rbp
ret