0% found this document useful (0 votes)
33 views2 pages

New 1

This program clears the screen, gets user input, and prints the input string on the screen in ascending or descending order depending on the shift key pressed. It uses BIOS interrupts to clear the screen, get input, and check the shift key. DOS interrupts are used to display characters.

Uploaded by

Aftab Rasheed
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)
33 views2 pages

New 1

This program clears the screen, gets user input, and prints the input string on the screen in ascending or descending order depending on the shift key pressed. It uses BIOS interrupts to clear the screen, get input, and check the shift key. DOS interrupts are used to display characters.

Uploaded by

Aftab Rasheed
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/ 2

ORG 1000h ; Set the origin address of the program

MOV AH, 06h ; Function to clear the screen


MOV AL, 0 ; Attribute (blank space) for clearing the screen
MOV BH, 00h ; Display page 0
MOV CX, 0 ; Upper left corner of the screen (row 0, column 0)
MOV DX, 184Fh ; Lower right corner of the screen (row 24, column 79)
INT 10h ; Call BIOS interrupt to clear the screen

MOV AH, 0Ah ; Function to read input string


MOV DX, OFFSET input_buffer ; Buffer to store input string
MOV AL, 10 ; Maximum length of the input string
INT 21h ; Call DOS interrupt to read input from the user

MOV SI, OFFSET input_buffer ; Pointer to the input string

; Print Name on the 1st row of the screen


MOV AH, 02h ; Function to display a character
MOV DL, 'Y' ; Replace 'Y' with the first character of your name
INT 21h ; Call DOS interrupt to display the character

MOV DL, 'o' ; Replace 'o' with the second character of your name
INT 21h

MOV DL, 'u' ; Replace 'u' with the third character of your name
INT 21h

; Print VUID on the 2nd row of the screen


MOV AH, 02h ; Function to display a character
MOV SI, OFFSET input_buffer ; Pointer to the input string

PRINT_VUID:
MOV AL, [SI] ; Load the current character from the VUID string
CMP AL, 0 ; Check if the character is null (end of string)
JE CHECK_SHIFT ; If yes, jump to check shift label

INT 21h ; Call DOS interrupt to display the character


INC SI ; Increment the pointer to the next character
JMP PRINT_VUID ; Repeat the loop for the remaining characters

CHECK_SHIFT:
MOV AH, 11h ; Function to check the state of the shift key
INT 16h ; Call BIOS interrupt to check the state of the shift key

CMP AH, 2 ; Check if right shift is pressed


JE PRINT_ASCENDING
CMP AH, 1 ; Check if left shift is pressed
JE PRINT_DESCENDING

EXIT:
MOV AH, 4Ch ; Function to exit the program
INT 21h ; Terminate the program

PRINT_ASCENDING:
MOV SI, OFFSET input_buffer ; Reset the pointer to the input string

; Print VUID in ascending order on the 3rd row of the screen


MOV AH, 02h ; Function to display a character
PRINT_ASCENDING_LOOP:
MOV AL, [SI] ; Load the current character from the VUID string
CMP AL, 0 ; Check if the character is null (end of string)
JE EXIT ; If yes, jump to exit label

INT 21h ; Call DOS interrupt to display the character


INC SI ; Increment the pointer to the next character
JMP PRINT_ASCENDING_LOOP ; Repeat the loop for the remaining characters

PRINT_DESCENDING:
MOV SI, OFFSET input_buffer ; Reset the pointer to the input string

; Print VUID in descending order on the 3rd row of the screen


MOV AH, 02h ; Function to display a character

; Find the end of the input string


FIND_END:
LODSB ; Load the next character from the input string
CMP AL, 0 ; Check if the character is null (end of string)
JNE FIND_END ; If not null, repeat the loop

DEC SI ; Move back one position to the last character

PRINT_DESCENDING_LOOP:
LODSB ; Load the current character from the input string
CMP AL, 0 ; Check if the character is null (end of string)
JE EXIT ; If yes, jump to exit label

INT 21h ; Call DOS interrupt to display the character


DEC SI ; Decrement the pointer to the previous character
JMP PRINT_DESCENDING_LOOP ; Repeat the loop for the remaining characters

; Data section
input_buffer DB 12 DUP('$') ; Buffer to store the input string (maximum 11
characters + null terminator)

END ; End of the program

You might also like