Question 7 (2 points) Let’s say you want to write a program for comparing two st
ID: 3849824 • Letter: Q
Question
Question 7 (2 points)
Let’s say you want to write a program for comparing two strings. You have a choice of using a 32-bit byte-addressable Big-endian or Little-endian architecture to do this. In either case, you can pack 4 characters in each word of 32-bits. Which one would you choose?
Question 7 options:
It must be Big-endian
It must be Little-endian
Either one works as long as you are consistent in the comparison.
Neither one works.
Question 8 (2 points)
Given the following load instruction
LW Rx, Ry, OFFSET ; Rx <- MEM[Ry + OFFSET]
Show how to realize a new addressing mode, called indirect, for use with the load instruction that is represented in assembly language as:
LW Rx, @(Ry) ;
Question 8 options:
LW Rx, Ry, 0
LW Rx, Rx, 0
LW Rx, Rx, 0
LW Ry, Rx, 0
ADD Rx, Ry, 0
LW Ry, Rx, 1
LW Rx, Ry, 0
LW Ry, Ry, 0
Question 9 (2 points)
Instruction "ld r1, 3(r2)" can do memory accessing. the semantics of this instruction is _________
Question 9 options:
The content in the memory cell addressed by "r1+3" is fetched and placed in register "r2".
The content in the memory cell addressed by "r2" is fetched and placed in register "r1".
The content in the memory cell addressed by "r2+3" is fetched and placed in register "r1".
The content in the memory cell addressed by "r2" is fetched and placed in register "r1+3".
Question 10 (2 points)
Consider the following array in memory with each element occupying four memory cells.
int a[100]
The starting memory address for this array is 2000. What is the starting address for element a[8]?
Question 10 options:
2000
2028
2032
2008
Question 11 (2 points)
Consider the following code, please point out the value of z after executing the code.
x=10; y=20; z=0;
if (x==y) z=8;
else z =15;
Question 11 options:
0
8
15
21
Question 12 (2 points)
_____ contains the first address on the stack that pertains to the activation record of the called procedure and never changes while this procedure is in execution.
Question 12 options:
stack pointer
frame pointer
program pointer
program counter
Question 13 (2 points)
Intel X86 is __________ architecture style.
Question 13 options:
stack oriented
memory oriented
register oriented
hybrid of memory-oriented and register-oriented
Question 14 (2 points)
________________ instructions are easy to implement, but waste space.
Question 14 options:
Fixed length
Variable length
Both fixed length and variable length
Neither fixed length nor variable length
Question 15 (2 points)
Consider the following high-level language code, which one is its assembly code implementation?
while(i ! = 0)
{
/* loop body */
t = t + b[i--];
}
Question 15 options:
be r1, r0, done;
loop body
....
done: ....
beq r1, r0, done;
loop body
....
done: ....
beq r1, r0, loop body;
loop body
....
done: ....
beq r1, r1, done;
loop body
....
done: ....
Question 16 (2 points)
The following assembly code implements _____ statement.
beq r1, r2, then
add r3, r6, r7
beq r1, r1, skip
then add r3, r4, r5
skip …
Question 16 options:
if
if ... else
switch
while
Question 17 (2 points)
Activation record is not used to store ________
Question 17 options:
caller saved register
program counter
return address
local variables
Question 18 (2 points)
Work out the details of implementing the switch statement using jump tables in assembly using any flavor of conditional branch instruction. The correct order is _______________.
1) Execute the desired branch
2) Continue with your original code
3) check the bounds of the switch variable
4) JLR or JMP $return_address
5) If the variable is within the bounds, you would index into the jump-table based on which switch case was executed.
Question 18 options:
3) 5) 1) 4) 2)
3) 1) 4) 2) 5)
5) 1) 2) 3) 4)
3) 2) 5) 1) 4)
Question 19 (2 points)
Consider the usage of the stack abstraction in executing procedure calls. The amount of memory included in the stack at any given time is controlled by simply changing the _____ pointer value.
Question 19 options:
program
frame
stack
memory
Question 20 (2 points)
Upon an interruption, which action is completed not by hardware?
Question 20 options:
save processor registers
save program counter
detect address of interrupt handler
disable interrupt
Question 21 (2 points)
The reason that we do not use JALR to return from the interrupt handler is __________.
Question 21 options:
After enable interrupts and JALR $k0, it may get a new interrupt that will trash $k0.
In between enable interrupts and JALR $k0, it may get a new interrupt that will trash $k0.
In between enable interrupts and JALR $k0, it may not get a new interrupt that will kill $k0.
Before enable interrupts and JALR $k0, it may get a new interrupt that will change the value in $k0.
It must be Big-endian
It must be Little-endian
Either one works as long as you are consistent in the comparison.
Neither one works.
Explanation / Answer
Answers for :
Question 7
Either one works as long as you are consistent in the comparison.
As In big endian, the most significant byte has been stored in the smallest address. And in little endian, the least significant byte has been stored in the smallest address .So we can use any one of the addressable memory to compare two strings .
Question 8
LW Rx, Rx, 0
LW Ry, Rx, 0
Question 9
The content in the memory cell addressed by "r2+3" is fetched and placed in register "r1".
Question 10
2032
Question 11
15
Question 12
stack pointer
Question 13
hybrid of memory-oriented and register-oriented
Question 14
Variable Length
Question 15
be r1, r0, done;
loop body
....
done: ....
Question 16
if ... else
Question 17
Program Counter
Question 18
3) 1) 4) 2) 5)
Question 19
frame
Question 20
save program counter
The content in the memory cell addressed by "r2+3" is fetched and placed in register "r1".
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.