-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcmp.asm
41 lines (38 loc) · 1.49 KB
/
cmp.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
;author : Priti Chattopadhyay
.model small ; assembler directive to allocate memory
.data ; data segment
msg1 db 10,13,"a>b$" ; message to be printed if a>b
msg2 db 10,13,"a<b$" ; message to be printed if a<b
msg3 db 10,13,"a=b$" ; message to be printed if a=b
a db 2h ; Different values of a and b for different scenarios
b db 2h
;a db 3h
;b db 5h
;a db 7h
;b db 1h
.code ; code segment
mov ax,@data ; initialize ds register
mov ds,ax
mov ah, a ; mov a to ah
mov al, b ; mov b to al
cmp ah,al ; compare ah and al
jb label2 ; jump to label2 if ah<al
je label3 ; jump to label3 if ah=al
label1:
lea dx, msg1 ; to print message 1[a>b]
mov ah,09h
int 21h
jmp exit ; unconditional jump to exit
label2:
lea dx,msg2 ; to print message 2[a<b]
mov ah,09h
int 21h
jmp exit ; unconditional jump to exit
label3:
lea dx,msg3 ; to print message 3[a=b]
mov ah,09h
int 21h
exit: ; exit label
mov ah,4ch ; terminate with return code
int 21h ; call the interrupt
end ; end directive