-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_1.ASM
More file actions
45 lines (40 loc) · 952 Bytes
/
2_1.ASM
File metadata and controls
45 lines (40 loc) · 952 Bytes
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
NAME EX2_1;add and subtract of two 16-bit binary numbers
;Copyleft(c), Siarnold, 2017
DATA SEGMENT
A1 DB 3H, 5H; adder one = 0503H
A2 DB 4H, 2H; adder two = 0204H
SUM DB 2 DUP(?)
DIF DB 2 DUP(?)
DATA ENDS
STACK SEGMENT PARA STACK
DB 100 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME DS:DATA, ES:DATA, SS:STACK, CS:CODE
START: MOV AX, DATA; the old 3 lines
MOV DS, AX
MOV ES, AX
MOV CX, 2;sum
MOV SI, 0
CLC
LOOP1: MOV AL, A1[SI]
MOV SUM[SI], AL
MOV AL, A2[SI]
ADC SUM[SI], AL
INC SI
DEC CX
JNZ LOOP1
MOV CX, 2;substract
MOV SI, 0
CLC
LOOP2: MOV AL, A1[SI]
MOV DIF[SI], AL
MOV AL, A2[SI]
SBB dif[SI], AL
INC SI
DEC CX
JNZ LOOP2
MOV AH, 4CH
INT 21H
CODE ENDS
END START