Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include io.h
- data segment
- x db ?
- y db ?
- a db ?
- b db ?
- z dw ?
- temp1 db ?
- temp2 db ?
- prompt1 db 'Enter x' ,0
- prompt2 db 'Enter y' ,0
- prompt3 db 'Enter a' ,0
- prompt4 db 'Enter b' ,0
- string db 40 DUP(?)
- ans db 'the sum is'
- sum db ?
- data ends
- code SEGMENT
- ASSUME CS:code, DS:data
- start: mov ax, SEG data
- mov ds, ax
- prompt: output prompt1
- inputs string,40
- atoi string
- mov x,al
- output prompt2
- inputs string, 40
- atoi string
- mov y,al
- output prompt3
- inputs string ,40
- atoi string
- mov a,al
- output prompt4
- inputs string ,40
- atoi string
- mov b,al
- mov al,x
- add al,y
- mov temp1, al
- mov al,a
- sub al,b
- mov temp2, al
- mov al,x
- sub al,y
- mov x, al
- mov al,a
- add al,b
- mov a, al
- mov al, x
- mov bl, a
- mul bl
- mov z,ax
- mov al, temp1
- mov bl, temp2
- mul bl ; result in ax
- div z
- itoa sum,al
- output al
- int 21h
- code ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment