ex3 db '3) r/s + s/r',10,'$' ex4 db '4) r*(s+15)',10,'$'
ex5 db '5) r^2 - r*s + s^2 ',10,'$'
a db ? b db ? s dw ? r dw ? q dw ? qs dw ? qr dw ? sup dw ? som dw ?
buff db ?
error db 'ERROR','$' data ends
code2 segment
assume cs:code2, ds:data, es:code
a1:
;3) r/s + s/r mov ax, 00 mov bx, 00 mov ax, [r] mov bx, [s] cmp ax, 0
jz check2 cmp bx, 0 jz check2 idiv bx mov [q], ax
mov dx, 00 mov ax, 00 mov bx, 00
mov ax, [s] mov bx, [r] idiv bx add ax, [q]
jmp far ptr c2
check2:
jmp far ptr erOut
a2:
;4) r*(s+15)
mov ax, [r] mov bx, [s] add bx, 15 mul bx
jmp far ptr c2
a3:
;5) r^2 - r*s + s^2
mov ax, [r] mov bx, [r] mul bx
mov [qr], ax mov ax, [s] mov bx, [s]
mul bx
mov [qs], ax mov ax,[r] mov bx,[s] mul bx
mov dx, ax
mov ax,[qr] sub ax, dx add ax, [qs] jmp far ptr c2
code2 ends
code segment
assume cs:code, ds:data, es:code2 input proc
push bx push cx push dx
mov ah,0Ah xor di,di
lea dx, [buff] mov [buff], 6 int 21h
mov dl,0Ah mov ah,02 int 21h xor ax,ax
mov bx,10
lea si,[buff+2]
metka_2: mov cl, [si] cmp cl, 0Dh jz endin cmp cl, '-' jz mt
cmp cl,'0' jb er
cmp cl, '9' ja er
sub cl,'0'
mul bx add ax,cx inc si
jmp metka_2
mt:
mov di,1 inc si
jmp metka_2
er:
lea dx, error mov ah, 09 int 21h
int 20h
endin: cmp di, 1 jz ng pop dx pop cx pop bx ret
ng: neg ax pop dx pop cx pop bx ret
input endp
output proc push bx push cx push dx
xor cx,cx mov bx,10
cmp ax, 0 js otr
cc: metka_1: xor dx,dx div bx push dx