-
Notifications
You must be signed in to change notification settings - Fork 0
/
2013-2.asm
62 lines (59 loc) · 887 Bytes
/
2013-2.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
;write an program that compares three 16bit digits in the given array
assume cs: codeseg, ds: dataseg, es: dataseg
dataseg segment
array dw 0000h, 0000h, 0002h
dataseg ends
codeseg segment
main proc far
start:
sub ax, ax
push ax
push ds
push es
mov ax, dataseg
mov ds, ax
mov es, ax
;use 3 different registers to stores 3 given number, and make comparison
;case 0: a = b = c
;case 1: a != b != c
;case 2: else
mov si, 0
mov ax, array[si]
mov bx, array[si+2]
mov dx, array[si+4]
mov cx, 0; stores number of equal pairs
cmp_1:cmp ax, bx
jne cmp_2
inc cx
cmp_2:cmp bx, dx
jne cmp_3
inc cx
cmp_3:cmp ax, dx
jne exit
inc cx
exit:
cmp cx, 0
je case_0
cmp cx, 3
je case_1
jmp case_2
case_0:
mov dl, '0'
mov ah, 02h
int 21h
jmp return
case_1:
mov dl, '1'
mov ah, 02h
int 21h
jmp return
case_2:
mov dl, '2'
mov ah, 02h
int 21h
return:
mov ax, 4c00h
int 21h
main endp
codeseg ends
end start