Skip to content

Instantly share code, notes, and snippets.

@tanayseven
Created July 31, 2012 20:22
Show Gist options
  • Save tanayseven/3220147 to your computer and use it in GitHub Desktop.
Save tanayseven/3220147 to your computer and use it in GitHub Desktop.
program to find the value of the foll. exp. (a+b)-(c+d) using 8086 compatible assembly language
;program to find the value of the foll. exp. (a+b)-(c+d)
INCLUDE io.h
Cr EQU 0ah
Lf EQU 0dh
data SEGMENT
p_a DB cr, lf, 'Enter a: ',0
p_b DB lf, 'Enter b: ',0
p_c DB lf, 'Enter c: ',0
p_d DB lf, 'Enter d: ',0
p_res DB cr, lf, 'The result is: ',0
tmpstr DW 40 DUP (?)
data ENDS
code SEGMENT
ASSUME cs:code, ds:data
start: mov ax, data
mov ds, ax
;input a
output p_a
inputs tmpstr, 10
atoi tmpstr
mov dx, ax
;input b
output p_b
inputs tmpstr, 10
atoi tmpstr
add dx, ax;(a+b)
;input c
output p_c
inputs tmpstr, 10
atoi tmpstr
mov bx, ax
;input d
output p_d
inputs tmpstr, 10
atoi tmpstr
add bx, ax;(c+d)
;find and output result
output p_res
sub dx, bx;(a+b)-(c+d)
mov ax, dx
itoa tmpstr, ax
output tmpstr
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