Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TITLE LAB4
- data segment
- check db 'AYE BRAT'
- enteer db 10, 13, '$'
- firstNum db 'First operand x1: $'
- secondNum db 'Second operand x2: $'
- answer db 'The answer is : $'
- error db 'incorrect number$'
- buff db 6,7 dup(?)
- x1 dw ?
- x2 dw ?
- a2 dw 4
- a3 dw 5
- b1 dw 1
- b3 dw 10
- data ends
- code2 segment
- assume cs:code2
- ;--------------------------------------------------
- function proc far
- lea dx,check
- mov ah, 09
- int 21h
- pop cx
- pop bx
- pop ax
- mul bx
- push ax
- mov ax,bx
- mul cx
- mov dx,ax
- pop ax
- add ax,dx
- add ax,cx
- push ax
- ret
- function endp
- ;---------------------------------------------------
- code2 ends
- ;---------------------------------------------------------------------------------------
- code segment
- assume cs:code,ds:data,es:code2
- begin:
- mov ax, data
- mov ds, ax
- xor ax, ax
- mov ax, code2
- mov es, ax
- xor ax, ax
- ;---------------------------------------
- ;first Num x1
- lea dx,firstNum
- mov ah, 09
- int 21h
- call InputInt
- mov [x1],ax
- xor ax,ax
- ;second Num x2
- lea dx,secondNum
- mov ah, 09
- int 21h
- call InputInt
- mov [x2],ax
- xor ax,ax
- mov ax,[x1]
- mov bx,[a2]
- mov cx,[a3]
- push ax
- push bx
- push cx
- call far ptr function
- mov di,ax
- mov ax,[b1]
- mov bx,[x2]
- mov cx,[b3]
- push ax
- push bx
- push cx
- call far ptr function
- sub ax,di
- push ax
- lea dx,answer
- mov ah, 09
- int 21h
- pop ax
- call OutInt
- lea dx,enteer
- mov ah, 09
- int 21h
- ;---------------------------------------EXIT
- mov ax, 4c00h
- int 21h
- ;---------------------------------------Proc:
- ;---------------------------------------Input
- InputInt proc
- push bx
- push cx
- push dx
- push di
- push si
- mov ah, 0Ah
- xor di, di
- lea dx, buff
- int 21h
- mov dl, 0Ah
- mov ah, 02
- int 21h
- xor ax,ax
- mov bx,10
- lea si, buff+2
- ii2:
- mov cl, [si]
- cmp cl, 0Dh ; 0Dh -- carriage return
- jz endin ; if zero or equal
- cmp cl, '0'
- jb er ; if smaller
- cmp cl, '9'
- ja er ; if greater
- sub cl, '0'
- mul bx
- add ax, cx
- inc si
- jmp ii2
- er:
- lea dx, error
- mov ah, 09
- int 21h
- int 20h
- endin:
- pop si
- pop di
- pop dx
- pop cx
- pop bx
- ret
- InputInt endp
- ;----------------------------------------Output
- OutInt proc
- xor cx,cx
- mov bx, 10
- oi2:
- xor dx,dx
- div bx
- push dx
- inc cx
- test ax,ax
- jnz oi2
- mov ah,02h
- oi3:
- pop dx
- add dl, '0'
- int 21h
- loop oi3
- ret
- OutInt endp
- ;---------------------------------------------------
- code ends
- ;---------------------------------------------------
- END begin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement