LEA Instruction Hanan alshaher the Input character can be stored in the data segment like this: .DATA MSG1 DB ‘ENTER A LOWERCASE LETTER: $’ MSG2 DB 'IN UPPER CASE IT IS: ' CHAR DB ?,’$’ LEA DX,MSG2 MOV AH,9 INT 21h Because MSG2 does not end with ‘$’, INT 21h goes on and displays the character- stored In CHAR. Hanan alshaher Home work solution Hanan alshaher Hanan alshaher Hanan alshaher Case Conversion Exercise : Write a program begins by prompting the user to enter a lowercase letter, and on the next line displays another message with the letter In uppercase. Hanan alshaher Solution .MODEL SMALL .STACK 100H .DATA MSG1 DB ‘ENTER A LOWER CASE LETTER: $’ MSG2 DB 0DH,0AH,‘IN UPPER CASE IT IS: ’ CHAR DB ?,’$’ .CODE MAIN PROC MOV AX,@DATA MOV DS,AX Hanan alshaher ; print user prompt LEA DX,MSG1 MOV AH,9 INT 21H ;input a character and convert to upper case MOV AH,1 INT 21H SUB AL,20H MOV CHAR,AL Hanan alshaher ;display on the next line LEA DX,MSG2 MOV AH,9 INT 21H ;DOS exit MOV AH,4CH INT 21H MAIN ENDP END MAIN Hanan alshaher .MOEDL SMALL .STACK 100K .DATA .CODE MAIN PRO MOV AX,@DATA MOV DS,AX MOV AH,4CH INT 21H MAIN ENDP END MAIN Hanan alshaher Programming Exercise (1) Write a program to (a) prompt the user, (b) read first, middle, and last initials of a person's name, and (c) display them down the left margin. Sample execution: ENTER THREE INITIALS: JFK J F K Hanan alshaher Hanan alshaher Hanan alshaher Hanan alshaher Programming Exercise (2) Write a program to display a 10 x 10 solid box of asterisks. Hint: declare a string in the data segment that specifies the box, and display it Hanan alshaher Hanan alshaher Hanan alshaher Hanan alshaher Programming Exercise (3) Write a program to translate the following high level language assignment statements into assembly language • A=B-A • A = - (A+ 1) • C=A+B • A=B-A-1 Hanan alshaher
© Copyright 2024