.
model small ; Small memory model (optional)
.stack 100h ; Allocate 100h bytes for stack
.data
num1 dw 1000h ; First number (change to your desired value)
num2 dw 2000h ; Second number (change to your desired value)
.code
main PROC
mov ax, @data ; Set DS register to data segment
mov ds, ax
; Load first number into AX
mov ax, num1
; Add second number to AX
add ax, num2
; Convert the sum in AX to ASCII for decimal display (multi-step process)
mov dx, 0 ; Initialize DX register for division
; Convert lower digit (AL) to ASCII (using division by 10)
mov cl, 10 ; Set divisor (10) for lower digit
div cl ; Divide AX by 10 (remainder in AL, quotient in DX)
add al, '0' ; Convert remainder (0-9) to ASCII by adding '0'
; Move ASCII for lower digit to another register for storage
mov bl, al
; Convert higher digit (AH) to ASCII (similar process)
mov al, ah ; Move higher digit (AH) to AL
mov ah, 0 ; Clear AH for division
div cl ; Divide AX by 10 (remainder in AL, quotient in DX)
add al, '0' ; Convert remainder (0-9) to ASCII by adding '0'
; Display the digits (higher digit first, then lower digit)
mov ah, 02h ; DOS function for character output
mov dl, ah ; Display higher digit
int 21h ; Call DOS interrupt for output
mov dl, bl ; Display lower digit
int 21h ; Call DOS interrupt for output
; Terminate the program
mov ah, 4ch ; Interrupt for program termination (INT 21h, AH=4ch)
int 21h ; Call interrupt to terminate the program
main ENDP
END main