Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views6 pages

Coal Assignment

The document contains two assembly language programs for DOS. The first program prompts the user to enter two numbers, adds them, and displays the result. The second program prompts the user to enter a character and then displays that character.

Uploaded by

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

Coal Assignment

The document contains two assembly language programs for DOS. The first program prompts the user to enter two numbers, adds them, and displays the result. The second program prompts the user to enter a character and then displays that character.

Uploaded by

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

COAL ASSIGNMENT

Q1

.model small
.stack 100h

.data
prompt1 db 'Enter first number: $'
prompt2 db 'Enter second number: $'
result_msg db 'The result is: $'
newline db 0Dh, 0Ah, '$'
num1 db 0
num2 db 0
result db 0

.code
main:
mov ax, @data
mov ds, ax
lea dx, prompt1
mov ah, 09h
int 21h

lea dx, newline


mov ah, 09h
int 21h

lea dx, num1


mov ah, 01h
int 21h
sub al, '0'
mov bl, al

lea dx, prompt2


mov ah, 09h
int 21h

lea dx, newline


mov ah, 09h
int 21h
lea dx, num2
mov ah, 01h
int 21h
sub al, '0'
mov cl, al

add bl, cl

lea dx, result_msg


mov ah, 09h
int 21h

lea dx, newline


mov ah, 09h
int 21h

add bl, '0'


mov dl, bl
mov ah, 02h
int 21h
lea dx, newline
mov ah, 09h
int 21h

mov ah, 4Ch


int 21h

end main

Q2
.model small
.stack 100h

.data
prompt db 'Enter a character: $'
newline db 0Ah, 0Dh, '$' ; Newline (carriage return + line feed)

.code
main:
; Initialize data segment
mov ax, @data
mov ds, ax

; Display the prompt message


mov ah, 09h ; DOS function to display string
lea dx, prompt ; Load address of the prompt string
int 21h ; Call interrupt 21h to print the string

; Read a single character from the user


mov ah, 01h ; DOS function to read a single character
int 21h ; Call interrupt 21h to get the character
mov dl, al ; Move the input character to DL (for printing)

; Print newline (next line)


mov ah, 09h ; DOS function to display string
lea dx, newline ; Load address of newline string
int 21h ; Call interrupt 21h to print newline
; Display the character
mov ah, 02h ; DOS function to print a character
int 21h ; Call interrupt 21h to display character in DL

; Exit the program


mov ah, 4Ch ; DOS function to terminate program
int 21h ; Call interrupt 21h to exit

end main

You might also like