-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulasm.asm
120 lines (84 loc) · 1.58 KB
/
mulasm.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
includelib ucrt.lib
includelib legacy_stdio_definitions.lib
includelib msvcrt.lib
option casemap:none
.data
real_a qword 3
real_b qword 4
real_ans qword ?
input_ans qword ?
fmtStrPrint db '%ld x %ld=?', 10, 0
fmtStrInput db '%ld', 0
fmtStrPrintOK db 'OK!', 10, 0
fmtStrPrintNotCorrect db 'NOT CORRECT! %ld', 10, 0
.code
externdef printf:proc
externdef scanf:proc
externdef _CRT_INIT:proc
externdef exit:proc
externdef rand:proc
externdef srand:proc
externdef time:proc
main proc
;int 3
call _CRT_INIT
push rbp
mov rbp, rsp
sub rsp, 32
go:
xor rcx,rcx
call time
mov rcx, rax
call srand
call rand
xor rdx,rdx
mov rcx, 10
div rcx
inc rdx
lea rsi, real_a
mov [rsi], rdx
call rand
xor rdx,rdx
mov ecx, 10
div ecx
inc rdx
lea rsi, real_b
mov [rsi], rdx
lea rsi, real_a
mov r8, [rsi]
lea rsi, real_b
mov rdx, [rsi]
lea rcx, fmtStrPrint
call printf
lea rsi, real_a
mov rax, [rsi]
lea rsi, real_b
mov rcx, [rsi]
mul rcx
lea rsi, real_ans
mov [rsi], rax
lea rdx, input_ans
lea rcx, fmtStrInput
call scanf
lea rsi, real_ans
mov rcx, [rsi]
lea rsi, input_ans
mov rax, [rsi]
cmp rcx, rax
jne not_correct
lea rcx, fmtStrPrintOK
call printf
jmp done
not_correct:
lea rdx, real_ans
mov rdx, [rdx]
lea rcx, fmtStrPrintNotCorrect
call printf
done:
jmp go
xor ecx, ecx ; the first argument for exit() is setting to 0
call exit
add rsp, 32
pop rbp
main endp
end