-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha9.asm
70 lines (58 loc) · 1.13 KB
/
a9.asm
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
64
65
66
67
68
69
70
;nasm 2.11.08
%macro write 2
mov eax,4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx,%1 ; Put the offset of hello in ecx
mov edx,%2
int 80h
%endmacro
section .data
count db 0h
c db 2h
y db 1
res db 2
section .text
global _start
_start:
mov rax,6h
label:
push rax
inc byte[count]
dec rax
cmp rax,1h
jne label
mov rax,1h
xor rcx,rcx
xor rdx,rdx
label2:
pop rcx
mul rcx
dec byte[count]
jnz label2
mov [res],rax
lea esi,[res+1h]
mov edi , 2h
temp:
mov bl, [esi] ; take value from array
rol bl, 04 ; to get higher nibble
l1:
mov al, bl
AND al, 0x0F ; to make upper 4 bits zero
add al, 30h
cmp al, 39h
jbe next
add al, 07h
next:
mov byte[y], al ; to print
write y, 1
mov bl, byte[esi]
dec byte[c] ; run the loop twice
mov al, byte[c]
jnz l1
mov byte[c],2h
dec rsi
dec rdi
jnz temp
mov eax,1 ; The system call for exit (sys_exit)
mov ebx,0 ; Exit with return code of 0 (no error)
int 80h;