Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following LC-3 program checks if the integer stored at memory location x5000 is divisible by 3. If yes, it stores the value 1 at

The following LC-3 program checks if the integer stored at memory location x5000" is divisible by 3. If yes, it stores the value 1 at memory location x5001, else it does nothing. Assume all the registers and the memory location x5001 have an initial value of 0.

a) (4 Points) Fill in the missing instructions of the code. Suggestion: Verify your solution by running it in PennSim.

0011 0000 0000 0000 ; Program starts at x3000

(i) ____ ____ ____ ____ ; Load value at x5000 into R0

(ii) ____ ____ ____ ____ ; Initialize R1 to 3

(iii) ____ ____ ____ ____ ; LOOP: calculate R0 - R1

(iv) ____ ____ ____ ____ ; Branch if positive to LOOP

(v) ____ ____ ____ ____ ; Branch if negative to HALT

(vi) ____ ____ ____ ____ ; Initialize R2 to 1

(vii) ____ ____ ____ ____; Store R2 to x5001

1111 0000 0010 0101 ; HALT

0101 0000 0000 0000 ; DATA1: x5000

(viii)____ ____ ____ ____; DATA2: x5001

b) (2 points) After the above program finishes execution, a value of 0 would mean that the integer at x5000 is not a multiple of 3. Does this program correctly identify all integers which are multiples of 3? If not, specify the integer(s) for which the program doesnt work, and why it does not work for those value(s).

c) (2 points) Briefly explain how you can fix the bug(s) identified in part b) ? Mention the names of the LC3 instructions, you would use to fix the bug

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions