程序代写代做 go assembly arm COMP􏰀􏰁􏰂􏰂/􏰃􏰁􏰂􏰂 Mid-Semester Exam

COMP􏰀􏰁􏰂􏰂/􏰃􏰁􏰂􏰂 Mid-Semester Exam
Semester 􏰄 􏰅􏰆􏰄􏰇
Name:
Student ID:
Time: 􏰄􏰓 minutes reading, 􏰈􏰆 minutes writing
Total marks: 􏰄􏰆􏰆
Permitted materials: 􏰄 double-sided A􏰉 cheat sheet
Instructions:
Questions are not equally weighted, and the sizes of answer boxes do not necessarily relate to the number of marks given for this question.
All answers must be written in the boxes provided in this booklet. You will be provided with scrap paper for working, but only the answers written in this booklet will be marked. Do not remove this booklet from the examination room. There is additional space at the end of the booklet in case the boxes provided are insufficient. If you use these extra pages, make sure you clearly label which question the answer refers to.
Greater marks will be awarded for simple, concrete answers than vague, rambling ones. Marks may be deducted for providing information that is irrelevant to a question.
For examiner use
􏰄

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
Question􏰏: CodeComprehension(􏰏􏰂marks)
.syntax unified .global main
.macro foo bar
ldr r1, [\bar] ldr r2, [\bar, #4] cmp r1, r2
beq end
.endm
main:
ldr r0, =numbers
label1:
foo r0 add r0, #4 b label1
end:
b end
.data
numbers:
.word 2, 3, 0, 0, 6, 3, 0, 0
Part􏰏 (􏰕marks)
Once this program reaches the end: label, what values will be in r1 and r2?
Part􏰀 (􏰕marks)
In one English sentence, what does this ARM assembly program do?
􏰅
Answer:
Answer:

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Question􏰀: DefusetheBomb(􏰁􏰂marks)
You’re a bomb defusal expert, and you come across this device. The four digits at the bot- tom represent a 􏰉-bit binary counter which will count down from 􏰄􏰄􏰄􏰄 (as shown) to 􏰆􏰆􏰆􏰆, with the least significant bit on the right. The bomb will explode when its “input wire” is 􏰄.
Part􏰏 (􏰏􏰂marks)
At what counter value will the bomb go off? Explain your answer.
Answer:
􏰐

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Part􏰀 (􏰏􏰂marks)
Imagine you have one battery which you can attach to one of the counter bits to keep it at 1 regardless of the state of the counter. Is there a single counter bit you could attach it to to stop the bomb going off? Explain your answer.
Answer:
Part􏰁 (􏰏􏰂marks)
Assume the values of the four counter bits are in the registers r0 to r3 as shown. Write a small ARM assembly program to calculate the value (0 or 1) of the bomb wire and store it in r4.
Answer:
􏰉

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Question􏰁: 􏰖-segmentdisplay(􏰁􏰂marks)
You’ve been asked to program a hardware device with a four-digit display like the one above. The device is just like your discoboard but with an additional 􏰐􏰅-bit display register dr which controls the display. For example, if the “A” bit is 􏰄, the top segment of the display will be on, if the “A” bit is 􏰆, it’ll be off (all but the 􏰇 lowest bits are unused). Each byte of the register controls the segments for a different display digit.
This is what all the digits 􏰆–􏰈 should look like on this display.
digit 3
digit 2
digit 1
digit 0
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
GFEDCBA GFEDCBA GFEDCBA GFEDCBA
􏰓

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Part􏰏 (􏰏􏰂marks)
In ARM assembly, write a short program which uses the dr register to show the number 7019 on the display.
Answer:
􏰔

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Part􏰀 (􏰀􏰂marks)
Write a new ARM assembly program which takes a decimal number (i.e. 􏰆–􏰈) in the regis- ter r0 and displays it on the right-most digit of the display. Make sure you include labels & comments to structure your code.
Question: should this question require handling a 􏰜-digit number, e.g. passed in through registers r0-􏰋? Or is it a good level as-is?
Answer:
􏰇

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
Answer:
􏰒

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Question􏰑: Functioncallingconventions(􏰁􏰂marks) Part􏰏 (􏰀􏰂marks)
Write an ARM assembly program which contains a function which implements Einstein’s famous E = mc2 equation, passing arguments & and returning the result using registers.
Answer:
􏰈

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
Answer:
􏰄􏰆

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam S􏰍 􏰊0􏰍􏰎
Part􏰀 (􏰏􏰂marks)
Re-implement the E = mc2 program, but this time passing arguments & and returning the result on the stack.
Answer:
􏰄􏰄

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
Answer:
􏰄􏰅

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰐

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰉

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰓

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰔

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰇

COMP􏰊􏰋00/􏰌􏰋00 Mid-Semester Exam
S􏰍 􏰊0􏰍􏰎
􏰄􏰒