Professional Documents
Culture Documents
Model Small
Model Small
model small
.stack 100h
.data
num1 db ?
num2 db ?
op db ?
msg db "error input$"
sum db ?
.code
main proc
mov ax, @data
mov ds, ax
start:
; Prompt for the first number
lea dx, msg1
mov ah, 9
int 21h
call newline
call newline
call space
call newline
call newline
call space
call newline
add1:
; Addition operation
mov al, num1
add al, num2
mov sum, al
call print
call newline
jmp restart
sub1:
; Subtraction operation
mov al, num1
sub al, num2
mov sum, al
call print
call newline
jmp restart
mul1:
; Multiplication operation
mov ah, 00h
mov al, num1
mov bl, num2
mul bl
mov sum, al
call print
call newline
jmp restart
div1:
; Division operation
mov ah, 00h
mov al, num1
mov bl, num2
div bl
mov sum, al
call print
call newline
jmp restart
restart:
; Prompt for restarting the program
lea dx, msg5
mov ah, 9
int 21h
call newline
print proc
mov dl, '='
mov ah, 2
int 21h
call space
mov bl, 10
mov ah, 00h
mov al, sum
div bl
mov dx, ax
add dx, 3030h
mov ah, 2
int 21h
mov dl, dh
int 21h
ret
space proc
mov dl, ' '
mov ah, 2
int 21h
ret
newline proc
mov dl, 0Dh
mov ah, 2
int 21h
mov dl, 0Ah
mov ah, 2
int 21h
ret