0% found this document useful (0 votes)
3 views

8bit addition and decimal display

This assembly language program performs addition of two hexadecimal numbers (1000h and 2000h) and converts the result to ASCII for display. It uses division to extract individual digits for output, displaying the higher digit first followed by the lower digit. The program concludes by terminating the execution using a DOS interrupt.

Uploaded by

kentrollins5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

8bit addition and decimal display

This assembly language program performs addition of two hexadecimal numbers (1000h and 2000h) and converts the result to ASCII for display. It uses division to extract individual digits for output, displaying the higher digit first followed by the lower digit. The program concludes by terminating the execution using a DOS interrupt.

Uploaded by

kentrollins5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

.

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

You might also like