-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask#03__Lab#10.asm
More file actions
77 lines (67 loc) · 1.13 KB
/
Task#03__Lab#10.asm
File metadata and controls
77 lines (67 loc) · 1.13 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
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
.model small
.stack 100h
.data
num1 dw 45
num2 dw 12
num3 dw 19
result dw 0
result_msg db 'The sum of three digits is:45, 12 and 19 $', 0
answer_msg db 'Answer: $', 0
.code
add_numbers macro
mov ax, num1
add ax, num2
add ax, num3
mov result, ax
endm
print_number macro
push ax
mov bx, 10
xor cx, cx
print_loop:
xor dx, dx
div bx
add dl, '0'
push dx
inc cx
test ax, ax
jnz print_loop
print_digits:
pop dx
mov ah, 2
int 21h
loop print_digits
pop ax
endm
display macro var
push ax
lea dx, var
mov ah, 9
int 21h
pop ax
endm
newline macro
mov dl, 10
mov ah, 2
int 21h
mov dl, 13
int 21h
endm
main proc
mov ax, @data
mov ds, ax
; Add the numbers
add_numbers
; Display result message
display result_msg
newline
; Display the answer label
display answer_msg
; Print the sum result
mov ax, result
print_number
; Exit program
mov ah, 4Ch
int 21h
main endp
end main