repeat a string Input: User enters a string, up to 30 characters output: We stor
ID: 3813277 • Letter: R
Question
repeat a string Input: User enters a string, up to 30 characters output: We store the string in memory and display it ;Add a line here to start your progran at address x30ee Part I Initialize :We allocated memory for the string already. LEA rl, str1 addr of array to store string Why are we using LEA here and not LD or LDI? AND r3, r3, a0 to store the size of the string/array AND r2, r2, ;Prompt user to enter the string LEA prompt PUTS Writes a string of ASCII characters to the console display from the address specified in Re ;Writing terminates with the occurrence of x0000 ;Part II: Read Store the string Start reading characters GETC is same as TRAP x20: Reads a char and stores its ASCII code in Re GETC Read a character ;ASCII for new line/carriage return is LF and it is stored at 1e Add a line here to check if the new chan is a carriage return. BRZ done echo character STR re ADD r1, r1, 1 advance ptr to array RAdd a line here to increment size of the array check if we reached max length ADD r4, r3, r6 BRN loop Part III: Display the string Add a line here to append NULL at the end of string ;Keep the label done. What is the ASCII char for NULL? Why are we adding NULL to the end of our string? Untitled Notepad File Edit Format View Help what would the ic3 editor version of this look like with the necessary added lines in the code.Explanation / Answer
.MODEL SMALL.STACK 100H
.CODE
MAIN PROC
MOV AH, 1 ; read a character
INT 21H
MOV BL, AL ; save input character into BL
MOV AH, 2 ; carriage return
MOV DL, 0DH
INT 21H
MOV DL, 0AH ; line feed
INT 21H
MOV AH, 2 ; display the character stored in BL
MOV DL, BL
INT 21H
MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP
END MAIN
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.