Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

; ; Program to repeat a string. ; Input: User enters a string, up to 30 characters ; Output: We store the string in memory

image text in transcribedimage text in transcribed

; ; Program to 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 program at address x3000 ;*************************************** ;Part I: Initialize ;*************************************** ;We allocated memory for the string already. LEA r1, str1 ; addr of array to store string ;Why are we using LEA here and not LD or LDI? AND r3, r3, #0 ; to store the size of the string/array AND r2, r2, #0 ;Prompt user to enter the string LEA r0, prompt1 ;PUTS writes a string of ASCII characters to the console display ;from the address specified in R0. ;Writing terminates with the occurrence of x0000 PUTS ;*************************************** ;Part II: Read / Store the string ;*************************************** ; ; Start reading characters ; ;GETC is same as TRAP x20: Reads a char and stores its ASCII code in R0 loop GETC ; Read a character. ;ASCII for newline/carriage return is LF and it is stored at #10 ;________ ;Add a line here to check if the new char is a carriage return. BRZ done out ; echo character STR r0, r1, #0 ADD r1, r1, #1 ; advance ptr to array ;________ ;Add a line here to increment size of the array LD r6, EOL ADD r4, r3, r6 ; check if we reached max length BRN loop ;*************************************** ;Part III: Display the string ;*************************************** done ;________ ;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? STR r0, r2, #0 ;________ ;Add a line here to add a carriage return to your string/array out LEA r0, str1 PUTS HALT prompt1 .STRINGZ "Enter a string of 30 characters or less. " str1 .BLKW 30 EOL .fill #-24 .end 
Objective Complete the given skeleton asm code to store and display a string. Problem Statement We are now familiar with the LC-3 simulator and can assemble and execute asm code. For this assignment, you are to develop a LC-3 assembly program to read a string provided by the user and redisplay it on the screen. A skeleton code is provided to you. The code is missing some lines, which are indicated by the following syntax: Add a line here to For instance, the first code you have to add asks: Add a line here to start your program at address x3000 You should replace this comment with the appropriate asm instruction, so that your program originates at memory address x3000 Two references you might find useful for this lab are the ASCII table' and the LC-3 instructions guide (on Blackboard). The expected program output is shown below. Objective Complete the given skeleton asm code to store and display a string. Problem Statement We are now familiar with the LC-3 simulator and can assemble and execute asm code. For this assignment, you are to develop a LC-3 assembly program to read a string provided by the user and redisplay it on the screen. A skeleton code is provided to you. The code is missing some lines, which are indicated by the following syntax: Add a line here to For instance, the first code you have to add asks: Add a line here to start your program at address x3000 You should replace this comment with the appropriate asm instruction, so that your program originates at memory address x3000 Two references you might find useful for this lab are the ASCII table' and the LC-3 instructions guide (on Blackboard). The expected program output is shown below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

Show the properties and structure of allotropes of carbon.

Answered: 1 week ago