//////////Multiplication
.data
message1 db 'Input first number: $'
message2 db 'Second number: $'
resultMessage db 'Result: $'
newline db 0Dh, 0Ah, '$'
.code
main:
mov ax, @data
mov ds, ax
mov ah, 9
lea dx, newline
int 21h
mov ah, 9
lea dx, message1
int 21h
mov ah, 1
int 21h
sub al, '0'
mov bl, al
mov ah, 9
lea dx, newline
int 21h
mov ah, 9
lea dx, message2
int 21h
mov ah, 1
int 21h
sub al, '0'
mul bl
mov bl,al
mov ah, 9
lea dx, newline
int 21h
mov ah, 9
lea dx, resultMessage
int 21h
add bl, '0'
mov dl, bl
mov ah, 2
int 21h
end main
//////////////////////////////// Division
.data
message db 'Input first number as dividend:$'
message1 db 'Input second number as divisor:$'
message2 db 'Quotent is:$'
message3 db 'Remainder is:$'
.code
@BUBT PRoc ; start procedure
;initialize data segment
MOV AX, @DATA ; store word size input value in AX register
MOV DS,AX ; store into memory RAM DS portion from AX register
;print input message
LEA DX,message ;load effective address
MOV AH,9 ; AH=9 (Function call for string print)
int 21h
;input 1st number
MOV AH,1 ; AH=1 (Function declaration for input)
int 21h ; interrupt service routine 21h or 33D
;function execute
MOV BL,AL ; BL= AL
SUB BL,30H ; convert Hexadecimal to decimal
;print new line
MOV AH,2
MOV DL,10
int 33
MOV DL,13
int 21h
;input message print
LEA DX,message1 ;load effective address
MOV AH,9 ; AH=9 (Function call for string print)
int 21h
;input 2nd number
MOV AH,1 ; AH=1 (Function declaration for input)
int 21h ; interrupt service routine 21h or 33D
;function execute
MOV BH,AL ; BH= AL
SUB BH,30H ; convert Hexadecimal to decimal
;print new line
MOV AH,2
MOV DL,10
int 33
MOV DL,13
int 21h
; print message
LEA DX,message2 ;load effective address
MOV AH,9 ; AH=9 (Function call for string print)
int 21h
;Division
MOV AX,0
MOV AL, BL ; AL= BL
DIV BH ; AL = AL / BH & AH = AL%BH
MOV BL , AL
ADD BL,30H
MOV BH,AH
ADD BH,30H
MOV AH,2 ; AH=2 (Function declaration for output)
MOV DL,BL; DL=BL
INT 21h ; function execute
;print new line
MOV AH,2
MOV DL,10
int 33
MOV DL,13
int 21h
; print message
LEA DX,message3 ;load effective address
MOV AH,9 ; AH=9 (Function call for string print)
int 21h
MOV AH,2 ; AH=2 (Function declaration for output)
MOV DL,BH; DL=BH
INT 21h ; function execute
@BUBT ENDP ; end procedure
END @BUBT; exit from procedure or program
////////////////greater equal
.data
message1 db 'Input first number: $'
message2 db 'Input second number: $'
greaterMessage db 'The greater number is: $'
equalMessage db 'Both numbers are equal: $'
newline db 0Dh, 0Ah, '$'
.code
main:
mov ax, @data
mov ds, ax
mov ah, 9
lea dx, newline
int 21h
mov ah, 9
lea dx, message1
int 21h
mov ah, 1
int 21h
sub al, '0'
mov bl, al
mov ah, 9
lea dx, newline
int 21h
mov ah, 9
lea dx, message2
int 21h
mov ah, 1
int 21h
sub al, '0'
mov bh, al
cmp bl, bh
ja bl_bigger
jb bh_bigger
je numbers_equal
bl_bigger:
mov ah, 9
lea dx, newline ; Print newline before result
int 21h
mov ah, 9
lea dx, greaterMessage
int 21h
mov dl, bl
add dl, '0'
mov ah, 2
int 21h
mov ah, 9
lea dx, newline
int 21h
mov ah, 4Ch
int 21h
bh_bigger:
mov ah, 9
lea dx, newline ; Print newline before result
int 21h
mov ah, 9
lea dx, greaterMessage
int 21h
mov dl, bh
add dl, '0'
mov ah, 2
int 21h
mov ah, 9
lea dx, newline
int 21h
mov ah, 4Ch
int 21h
numbers_equal:
mov ah, 9
lea dx, newline ; Print newline before result
int 21h
mov ah, 9
lea dx, equalMessage
int 21h
mov dl, bl
add dl, '0'
mov ah, 2
int 21h
mov ah, 9
lea dx, newline
int 21h
mov ah, 4Ch
int 21h
end main