-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsumOfTwoArrays.asm
More file actions
97 lines (63 loc) · 1.98 KB
/
Copy pathsumOfTwoArrays.asm
File metadata and controls
97 lines (63 loc) · 1.98 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;sum of two array verion
.MODEL SMALL
.STACK .100h
.DATA
inputOneMessage db 'Insert first number: $'
inputTwoMessage db 'Insert second number: $'
numberOne db 3 dup(0) ; number array, to output to console needs to add 48, '0' or '30h'
numberTwo db 3 dup(0) ; number array, to output to console needs to add 48, '0' or '30h'
result db 3 dub(0)
newline db 13, 10, '$' ; Carriage Return and Line Feed make up a newline.
.CODE
MOV AX, @DATA ; load data segment
MOV DS, AX ; load data segment
MOV AX, 03h ; set video mode configuration
INT 10h
MOV DX, OFFSET inputOneMessage
MOV AH, 09h
INT 21h
MOV CX, 3
MOV SI, OFFSET numberOne
readBitNumberOne:
MOV AH, 01H ; read keyboard character function
INT 21H
CMP AL, 13 ; compare input to enter key.
JE end_inputNumberOne
SUB AL, '0' ; convert from ascii code to binary (could also use 30h)
MOV [SI], AL
INC SI
LOOP readBitNumberOne
end_inputNumberOne:
; NEWLINE
MOV DX, OFFSET newline
MOV AH, 09H
INT 21H
MOV DX, OFFSET inputTwoMessage
MOV AH, 09H
INT 21H
MOV CX, 3
MOV SI, OFFSET numberTwo
readBitNumberTwo:
MOV AH, 01H ; read keyboard character function
INT 21H
CMP AL, 13 ; compare input to enter key.
JE end_inputNumberTwo
SUB AL, '0' ; convert from ascii code to binary (could also use 30h)
MOV [SI], AL
INC SI
LOOP readBitNumberTwo
end_inputNumberTwo:
; newline
MOV DX, OFFSET newline
MOV AH, 09H
INT 21H
calculate_result:
mov di, offset result
mov si, offset numberOne
add si, 2
add di, 2
mov dx, [si]
add dx, ax
MOV AX, 4C00h ; Exit program
INT 21h
END