-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task13.asm
45 lines (30 loc) · 794 Bytes
/
Task13.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
Difference of two sets (S1-S2) is a set having elements of S1 which are NOT Present in S2, see following examples for detail. Your task is to write a subroutine in Assembly Language that finds Difference of two sets (S1-S2). Note that both the sets are sorted and have distinct elements only.
[org 0x0100]
S1: db -3, -1, 2, 5, 6, 8, 9
S2: db -2, 2, 6, 7, 9
diff: db 0,0,0,0,0,0,0
Subtract:
xor di, di
xor si, si
xor bx, bx
next:
cmp di, 7
je end
cmp bx, 3
je copy
mov al, [S1 + di]
mov dl, [S2 + bx]
cmp al, dl
je skip
mov [diff + si], al
mov dx,[diff + si]
inc si
skip:
inc di
inc bx
jmp next
copy:
rep movsb
end :
mov ax,0x4c00
int 0x21