Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- mov ah, 9h
- mov dx, task1
- int 21h
- mov ah,9h
- mov dx, task2
- int 21h
- mov ah, 09h
- mov dx, inputA
- int 21h
- mov ah, 0ah
- mov dx, strA
- int 21h
- mov bx, dx
- call get_number
- mov si, ax
- mov ah, 02h
- mov dx, 0x0D0A
- int 21h
- mov ah, 09h
- mov dx, inputB
- int 21h
- mov ah, 0ah
- mov dx, strB
- int 21h
- mov bx, dx
- call get_number
- mov bx, ax
- call get_result
- mov ax, [res]
- call output_number
- mov ah, 8h
- int 21h
- ret
- get_result:
- mov ax, si
- mov si, bx
- mov [A], ax
- mov [B], si
- mov cx, 3h
- dec cx
- loopA: mul [A]
- loop loopA
- mov bx, ax
- mov ax, si
- mov cx, 2h
- dec cx
- loopB: mul [B]
- loop loopB
- sub bx, ax
- mov [res], bx
- ret
- get_number:
- xor ax, ax
- xor dx, dx
- add bx, 1h
- mov cl, [bx]
- lp:
- inc bx
- mul [cm]
- add al, [bx]
- sub ax, '0'
- loop lp
- ret
- output_number:
- push '*'
- lpt:
- div [cm]
- push dx
- xor dx, dx
- cmp ax, 0h
- jne lpt
- mov ah, 02h
- mov dx, 0x0D0A
- int 21h
- lpp:
- pop bx
- cmp bx, '*'
- je endst
- add bx, '0'
- mov ah, 02h
- mov dx, bx
- int 21h
- jmp lpp
- endst: ret
- cm dw 10
- inputA db "Enter number A: $"
- inputB db "Enter number B: $"
- task1 db "This program calculates A^3 - B^2",$0d,$0a, "$"
- task2 db "Using registers", $0d, $0a, "$"
- new_line db $0d, $0A, "$"
- strA db 10, 0, 10 dup(?)
- strB db 10, 0, 10 dup(?)
- A dw 0h
- B dw 0h
- res dw 0h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement