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 12:50
What aspects of lines have to be diffrent
Answers: 3
question
Mathematics, 21.06.2019 17:00
Which inequality comparing two of the expressions is true when 0.7 < x < 0.9
Answers: 1
question
Mathematics, 21.06.2019 18:00
If f(x) = 4x – 3 and g(x) = 8x + 2, find each function value a.f[g(3)] b.g[f(5)] c.g{f[g(-4)]}
Answers: 3
question
Mathematics, 21.06.2019 20:30
Martha has a deck of cards. she has lost some of the cards, and now the deck only contains nine spades, eleven diamonds, eight clubs, and twelve hearts. martha predicts that whenever she draws a card from the deck without looking, she will draw a club one-fifth of the time. which activity would best allow martha to test her prediction? a. randomly draw a card from the box and see if it is a club. b. randomly draw a card. then, continue to draw another card until all eight clubs are drawn. c. randomly draw and replace a card 120 times. then, observe how close to 30 times a club is drawn. d. randomly draw and replace a card 100 times. then, observe how close to 20 times a club is drawn.
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
Mathematics, 27.07.2019 04:30