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

Task

The document contains three separate assembly language programs. The first program prompts the user to enter a character and prints it 50 times, the second prompts for two characters and displays them, while the third program asks for a number and compares it to 5, displaying an appropriate message based on the comparison. Each program is structured with data definitions, input handling, and output messages using DOS interrupts.

Uploaded by

bristyangel1823
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Task

The document contains three separate assembly language programs. The first program prompts the user to enter a character and prints it 50 times, the second prompts for two characters and displays them, while the third program asks for a number and compares it to 5, displaying an appropriate message based on the comparison. Each program is structured with data definitions, input handling, and output messages using DOS interrupts.

Uploaded by

bristyangel1823
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

.

MODEL SMALL
.STACK 100H
.DATA
M1 DB "Enter a character: $"
CHAR DB ?
M3 DB 0AH,0DH, "THANK YOU. $"
M2 DB 0AH,0DH, "OUTPUT IS: $"

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

; Display prompt message


MOV AH, 9 ; 9 is string output and AH is the
higher byte
LEA DX, M1 ; Load the address msg
INT 21H ; For Display call

; Read a character from the user


MOV AH, 1
INT 21H
MOV CHAR, AL ; Store the entered character

; Create a new line (Line Gap)


MOV AH,2
MOV DL,13 ; Carry at the first of the line
INT 21H
MOV DL,10 ; Start a new line
INT 21H

; Print a newline
MOV AH, 9 ; 9 is string output and AH is the
higher byte
LEA DX, M2 ; Load the address msg
INT 21H

; Print the character 50 times


MOV CX, 50 ; Set counter to 50

LOOP_START:
MOV AH, 2 ; Interrupt character
MOV DL, CHAR ; Load the character to print
INT 21H
DEC CX ; Decrement counter
JNZ LOOP_START ; Repeat until CX == 0

; Display message
MOV AH, 9
LEA DX, M3
INT 21H

; End the program


MOV AH, 4CH ; Hexa decimal value to start exit
INT 21H

MAIN ENDP ; Endp is the end procedure


END MAIN

.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB "Enter Characters: $"
OUTPUT DB 0AH, 0DH, "Output is: $"
VAR DB 3 DUP('$') ; Reserve 3 bytes: 2 for characters, 1 for the end-of-string
marker '$'

.CODE
MAIN PROC

MOV AX, @DATA


MOV DS, AX

; Display prompt message


MOV AH, 9
LEA DX, PROMPT
INT 21H

; Read first character and store in VAR


MOV AH, 1
INT 21H
MOV VAR, AL ; Store first character in the first byte of VAR

; Read second character and store in VAR+1


MOV AH, 1
INT 21H
MOV VAR + 1, AL ; Store second character in the second byte of VAR

; Add string terminator ('$') to VAR+2


MOV BYTE PTR VAR + 2, '$'

; Display output message


MOV AH, 9
LEA DX, OUTPUT
INT 21H

; Display the stored characters


MOV AH, 9
LEA DX, VAR
INT 21H

; End program
MOV AH, 4CH
INT 21H

MAIN ENDP
END MAIN

.MODEL SMALL
.STACK 100H
.DATA
M1 DB "Enter Any Number: $"
M2 DB 0AH,0DH, "The ENTERED Number is LESS than 5$"
M3 DB 0AH,0DH, "The ENTERED Number is GREATER than 5$"
M4 DB 0AH,0DH, "The ENTERED Number is EQUAL to 5$"

.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

; Display prompt message


MOV AH,9 ; 9 is string output and AH is the higher byte
LEA DX,M1
INT 21H

; User input
MOV AH,1 ; Take input where AH is the higher bytes
INT 21H
SUB AL,'0' ; Convert ASCII to integer

; Compare the input with the value in CL


MOV BL,5 ; Set CL to 5
CMP AL,BL ; Compare AL with L
JL LESS ; Jump if input < 5
JG GREATER ; Jump if input > 5
JE EQUAL ; Jump if input == 5

LESS:
MOV AH,9
LEA DX,M2
INT 21H
JMP END ; Exit after displaying message

GREATER:
MOV AH,9 ; 9 is string output and AH is the higher byte
LEA DX,M3
INT 21H
JMP END ; Exit after displaying message
EQUAL:
MOV AH,9 ; 9 is string output and AH is the higher byte
LEA DX,M4
INT 21H

END:
; End the program
MOV AH,4CH ; Hexa decimal value to start exit
INT 21H

MAIN ENDP ; Endp is the end procedure


END MAIN
Write to Faiaz Rahman Fahim

You might also like