Skip to content

Instantly share code, notes, and snippets.

@tanayseven
Created July 31, 2012 20:23
Show Gist options
  • Save tanayseven/3220161 to your computer and use it in GitHub Desktop.
Save tanayseven/3220161 to your computer and use it in GitHub Desktop.
program to enter 2 nos. and check the largest of the two using 8086 compatible assembly language
;program to enter 2 nos. and check the largest of the two
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
data SEGMENT
p_n1 DB cr, lf, 'Enter n1: ',0
p_n2 DB lf, 'Enter n2: ',0
r_n1 DB cr, lf, 'n1 is larger than n2',0
r_n2 DB cr, lf, 'n2 is larger than n1',0
r_bt DB cr, lf, 'Both are equal',0
tmpstr DW 40 DUP (?)
data ENDS
code SEGMENT
ASSUME cs:code, ds:data
start: mov ax, data
mov ds, ax
;input n1
output p_n1
inputs tmpstr, 10
atoi tmpstr
mov dx, ax
;input n2
output p_n2
inputs tmpstr, 10
atoi tmpstr
cmp dx, ax;(n1>n2)
jz l_equ;jump if equal to
jg l_grtr;jump if greater than
output r_n2;else continue exec
jmp quit
l_equ: output r_bt
jmp quit
l_grtr: output r_n1
quit: mov al, 00h
mov ah, 4ch
int 21h
code ENDS
END start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment