-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathNumbers.asm
70 lines (56 loc) · 1.68 KB
/
Numbers.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
.386
.model flat, stdcall
option casemap :none
include C:\masm32\include\windows.inc
include C:\masm32\include\masm32.inc
include C:\masm32\include\kernel32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\kernel32.lib
.data
Number1 dword 0
Number2 dword 0
UserInput1 db 10 DUP(0)
UserInput2 db 10 DUP(0)
Message1 db "Enter First Number: ",0
Message2 db "Enter Second Number: ",0
SumString db 10 DUP(0)
SubString db 10 DUP(0)
Message3 db "The sum of the Numbers is: ",0
Message4 db "The difference of the Numbers is: ",0
NumSum dword 0
NumSub dword 0
.code
start:
; user Input.
invoke StdOut, addr Message1
invoke StdIn, addr UserInput1, 10
invoke StdOut, addr UserInput1
invoke StdOut, addr Message2
invoke StdIn, addr UserInput2, 10
invoke StdOut, addr UserInput2
; Remover CRLF
invoke StripLF, addr UserInput1
invoke StripLF, addr UserInput2
; Convertir Strings a numeros.
invoke atodw, addr UserInput1
mov Number1, eax
invoke atodw, addr UserInput2
mov Number2, eax
; Suma
mov eax, Number1
add eax, Number2
mov NumSum, eax
;Resta
mov eax, Number1
sub eax, Number2
mov NumSub, eax
;Convertir numeros a strings
invoke dwtoa, NumSum, addr SumString
invoke dwtoa, NumSub, addr SubString
;Pintar por pantalla
invoke StdOut, addr Message3
invoke StdOut, addr SumString
invoke StdOut, addr Message4
invoke StdOut, addr SubString
invoke ExitProcess,0
end start