subject
Mathematics, 28.11.2019 03:31 cchavcchav9606

For your programs in problems 1: write the instruction address, the binary lc-3 instruction, and the corresponding rtl or assembly in the following format:

0001 001 010 1 00100 ; r1 ← r2 + 4

0001 001 010 1 00100 ; add r1, r2, #4

note how bits are arranged in groups that correspond to instruction-specific operands.

if you are not sure about the rtl format of a certain instruction, you can refer to appendix a of your patt & patel text or read sections 5.5 and 6.1. try to make your program as simple and intuitive as you can.

lc-3 programming in machine language

1) for each of the following tasks, systematically decompose the problem to the level of lc-3 instructions, then write lc-3 instructions to implement your solution. turn in your flow chart and lc-3 instructions in binary. for credit, each instruction must be annotated with a comment in rtl or assembly.

a) write a program that computes r3−r4 and stores the result in r5. to receive credit, you can only modify the contents of r5, and no other register, and your solution should have no more than 6 lines of code.

b) write a program that computes the absolute value of the number stored in r1, and stores the result in r0. to receive credit, you can only modify the contents of r0, and no other register, and your solution should have no more than 7 lines of code.

c) assuming that r2≥0, write a program that determines if the value stored in r2 is even. if r2 is even, store in r1 the value 1, otherwise store the value -1. to receive credit, you can only modify the contents of r1, and no other register, and your solution should have no more than 7 lines of code.

d) write a program that adds each of the numbers stored in memory locations d through e, inclusive, and stores the result in register r2. assume that address d can be found in register r3 and address e can be found in register r4. to receive credit, you can only modify the contents of r2, r3, r4, r5, and no other registers, and your solution should have no more than 12 lines of code.

e) multiplication of two integers can be achieved by repeated additions. similarly, division of two integers can be achieved by repeated subtractions. assume that r0≥0 and r1> 0. write a program that computes r0÷r1 and stores the quotient in r2. (the program does not need to store the remainder.) to receive credit, you can only modify the contents of r0, r1, r2, and no other registers, and your solution should have no more than 10 lines of code.

f) write a program that counts the number of bits equal to one in r1, and stores the result in r2. for example, if r1=x0a0c, then r2=x0004 after the program runs. to receive credit, you can only modify the contents of r1 and r2, and no other register, and your solution should have no more than 9 lines of code.

ansver
Answers: 2

Another question on Mathematics

question
Mathematics, 21.06.2019 19:00
Pyotr tchaikovsky sporting goods operates on a 45% overhead based on the selling price, which results in an overhead of $65.34 on the newest version of an air hockey game set. if the air hockey game set costs pyotr tchaikovsky sports $49.32, find the selling price, the markup, and the net profit.
Answers: 2
question
Mathematics, 21.06.2019 19:00
What is the factored form of the following expressions? d^2 – 13d + 36
Answers: 2
question
Mathematics, 21.06.2019 22:20
Which strategy is used by public health to reduce the incidence of food poisoning?
Answers: 1
question
Mathematics, 22.06.2019 00:30
On ryan's last social studies test there were two types of questions true/false worth 3 points each and multiple choice questions worth 4 points each
Answers: 3
You know the right answer?
For your programs in problems 1: write the instruction address, the binary lc-3 instruction, and th...
Questions
question
English, 24.08.2021 15:50
question
Computers and Technology, 24.08.2021 15:50
question
English, 24.08.2021 15:50
question
Mathematics, 24.08.2021 16:00
Questions on the website: 13722359