-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.asm
76 lines (53 loc) · 1.13 KB
/
test.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
.model small
.stack 100h
.data
prompt db 13, 10, 'First number:','$'
prompt db 13,10, 'Second number:', '$'
result db 13, 10, 'Sum','$'
;Variables
num1 db ?
num2 db ?
sum db ?
.code
main proc
mov ax,@data ;get data segment address
mov ds,ax ;initialize ds
;Display Prompt
mov ah,9 ;print string function
mov dx,offset prompt;ds:dx points to string
int 21h
; Numbers from the user
mov ah,1 ;input function
int 21h
mov bl,al ;save the value from input
mov num1,al
mov ah,9
lea dx, prompt ;print prompt
int 21h
mov ah,2 ;input second function
int 21h
mov bh,al ;save the value from second input
mov num2,al
;Addition
mov ax,num1 ;move num1 into ax
add ax,num2 ;add first and second numbers together
mov sum,ax ;move the total sum of numbers in sum
;Print Sum
mov ah,9
lea dx, result ; print result
int 21h
mov ah,2
mov dl,bl
int 21h
mov dl,'+' ;display + sign
int 21h
mov dl,bh
int 21h
mov dl,'=' ;display = sign
int 21h
mov dl,bh
int 21h
mov ah,4ch
int 21h
main endp
end main