Question: Write a program in assembly for the LC3. The first line should be the starting address in memory, use 3000 to be safe. The last

Write a program in assembly for the LC3.

The first line should be the starting address in memory, use 3000 to be safe.

The last line should be a halt (F025).

The lines between the first and last line should do the following: Print a number of digits specified in R1. These digits should start with 0 and count up and then stop at R1 1.

For example:

If 5 is in R1, the program would print 01234

If 9 is in R1, your program would print 012345678

You can assume R1 will never be less than zero or greater than 10. Do not initialize R1 in the program. Assume the value will already be in R1 when your program starts.

Write your program in assembly. Convert it manually to hex.

A possible algorithm. Copy the ASCII code for zero to a register. R0 would be easiest.

while (R1 indicates not done) {

print ascii

ascii ++

R1 --

}

The equivalent to the above in LC3 assembly might look something like this.

Copy the ASCII code for zero to a register. R0 would be easiest.

If R1 indicated done, branch to end.

print ascii

add 1 to ascii

R1 --

Branch back to if statement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!