Skip to content

Instantly share code, notes, and snippets.

@douglas-vaz
Created July 11, 2012 10:05
Show Gist options
  • Save douglas-vaz/3089411 to your computer and use it in GitHub Desktop.
Save douglas-vaz/3089411 to your computer and use it in GitHub Desktop.
MM
include io.h
cr equ 0dh
lf equ 0ah
data segment
la db cr,lf,'Enter a',0
lb db cr,lf,'Enter b',0
l1 db cr,lf,'Enter x',0
ly db cr,lf,'Enter y',0
f dw 40 dup(?)
a db ?
b db ?
x db ?
y db ?
data ends
code segment
assume cs: code, ds:data
start: mov ax,data
mov ds,ax
output l1
inputs f,40
atoi f
mov x,ax
output ly
inputs f,40
atoi f
mov y,ax
output la
inputs f,40
atoi f
mov a,ax
output lb
inputs f,40
atoi f
mov b,ax
add dx,a ;dx = a+b
mov cx,a
sub cx,ax ;cx = a-b
mov bx,x
mov ax,y
add ax,bx ;ax = x+y
sub bx,y ;bx = x-y
imul cx ;ax = (x+y)(a-b)
mov cx,ax ;cx = (x+y)(a-b)
mov ax,bx;
imul dx
mov bx,ax ;bx = (x-y)(a+b)
mov ax,cx;
cwd
idiv bx
itoa f,ax
output f
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