



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




EXAMPLE 1 : about inputs and outputs (problem 9 from the book) An
Assembly Language Program that :
a. prompt the user to enter 3 initials
b. read first, middle, and last^ initials^ of^ a person's^ name c. display each character in a new line
MSG DB CR,LF, ’Enter 3 Characters : $' NewLine DB LF,CR,'$' .CODE
; the next 3 line of code will allow us to print something on the ; screen , in this case it will print out MSG
MOV AH,9 ; display string function LEA DX,MSG ; get message INT 21H ; display message
; the next 3 line of code will allow us to take a single input from ;the user which is the first initial and save it BL
MOV AH,1 ; read character function INT 21H ; characte in AL MOV BL,AL ; save character in BL
; the next 3 line of code will allow us to take a single input from ;the user which is the second initial and save it in BH
MOV AH,1 ;^ read^ character^ function
INT 21H ; characte in AL MOV BH,AL ; save character in BH
; the next 3 line of code will allow us to take a single input from ; the user which is the third initial and save it in CL
MOV AH,1 ; read character function INT 21H ; characte in AL MOV CL,AL ; save character in CL
; the next 3 line of code will allow us to print something on the ; screen, in this case it will print out an empty new line
MOV AH,9 ; display string function LEA DX,NewLine ; get message INT 21H ;display message
; the next 3 line of code will allow us to print a single character on ;the screen , in this case it will print out the first initial entered ;by the user (saved earlier in the BL)
MOV AH,2 ; display single character function MOV DL,BL ; get character from BL INT 21H ; display character
; the next 3 line of code will allow us to print something on the ; screen, in this case it will print out an empty new line again
MOV AH,9 ; display string function LEA DX,NewLine ; get message INT 21H ;display message
; the next 3 line of code will allow us to print a single character on ;the screen , in this case it will print out the second initial ;entered by the user (saved earlier in the BH)
MOV AH,2 ;^ display^ single^ character^ function MOV DL,BH ; get character from BH INT 21H ; display character
;Solving the same problem in another way instead of assigning each ;character to a register we will assign each character to a variable
MAIN ENDP
END MAIN