


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive set of multiple-choice questions and exercises designed to test understanding of mips assembly language programming. it covers topics such as data memory addressing, register usage, instruction execution, subroutines, and stack operations. The questions are suitable for university or high school students studying computer architecture or assembly language programming.
Typology: Exams
1 / 42
This page cannot be seen from the preview
Don't miss anything!



































CDA Final Exam complete Study Guide solution MIPSzy Data Memory begins at address _____. a.) 0 b.) $zero c.) 1024 d.) 4096 - 4096 In MIPSzy, the addressability is _____. a.) 2^32 words b.) 32 bits c.) 8 bits d.) 4096 bits - 32 bits A comment in MIPSzy begins with a.)! b.) // c.) # d.) /* - # MIPSzy's Register file has _____ registers. a.) 16 b.) 7 c.) 32
d.) 8 - 8 but actual MIPS has up to 32 True or False: $t0 is a read-only register. - False What is in $t1 after the execution of the following MIPSzy program? addi $t1, $zero, 1 addi $t2, $t1, 1 bne $t1, $t2, end add $t1, $t2, $t end: addi $t1, $t1, 1 a.) 2 b.) 0 c.) 1 4.) 4 - 2 Which instructions compute $t2 = $t1 + $t1 + 5? a.) addi $t2, $t1, 5 addi $t2, $t2, $t b.) addi $t2, $t1, 5 add $t2, $t2, $t
Which of the following MIPSzy programs is invalid? a.) addi $t0, $zero, 5000 lw $t1, 0($t0) b.) addi $t0, $zero, 4092 lw $t1, 0($t0) c.) addi $t0, $zero, 5252 sw $t1, 0($t0) d.) addi $t0, $zero, 4096 lw $t1, 0($t0) - b Assume: $t0: 10 $t1: 10 $t2: 15 $t3: 21 What is in $t3 after the execution of the following MIPSzy program? beq $t0, $t1, end addi $t3, $t3, 5
(DM[5100]) into $t0?
c.) addi $t1, $t2, 1 d.) beq $t1, $t2, target - b True or False: A subroutine should push all the registers it uses onto the program stack at the beginning of the subroutine. - True A subroutine is returned using the instruction _____? a.) return b.) end c.) j $ra d.) jr $ra - jr $ra Which register holds the top of the program stack? a.) $sp b.) $t1, c.) $t d.) $ra - $sp A subroutine is called using the instruction: a.) call b.) jal c.) sub d.) j - jal Which register holds the subroutine return address?
a.) $ra b.) $t c.) $sp d.) $t3 - $ra Assume that a subroutine, sub, is loaded beginning at address 1000. A program calls sub with the instruction: jal sub. If jal sub is at address 2000, what is in $ra after jal sub executes? a.) 2000 b.) 1000 c.) 2004 d.) 1004 - c What address the assembler will use for the label "equal" when it translates the program given below to machine instructions? beq $t1, $zero, equal add $t1, $t2, $t j done equal: add $t1, $t2, $t done: add $t1, $t1, $t Assume that the program is loaded in the instruction memory beginning at address 200. a.) 216 b.) 203
c.) decrement $sp by 4 d.) increment $sp by 1 - For a subroutine with 3 arguments and a return value which instruction stores $t0 into the stack entry allocated for the return value? Assume that the subroutine is only using $t0 and that $t0's original value is already pushed onto the stack at the beginning of the subroutine. a.) sw $t0, 0($sp) b.) sw $t0, 8($sp) c.) sw $t0, 12($sp) d.) sw $t0, 4($sp) - d Which of the following statements about MIPSzy machine level instruction is true? a.) all instructions are 16 bits b.) instructions are either 32 or 16 bits c.) instructions are variable length d.) all instructions are 32 bits - all instructions are 32 bits What is $t0 after the following program terminates? addi $t0, $zero, 3 sw $t0, 0($sp) addi $sp, $sp, - jal sub lw $t1, 0($sp) add $t1, $t0, $t
addi $sp, $sp, 8 j end sub: addi $sp, $sp, - sw $t0, 0($sp) lw $t0, 8($sp) mul $t0, $t0, $t sw $t0, 4($sp) lw $t0, 0($sp) addi $sp, $sp, 4 jr $ra end: a.) 8 b.) 9 c.) 3 d.) 12 - c Which of the following instructions will push $t0 onto the program stack? Which of the following instructions will push $t0 onto the program stack a.) sw $t0, 0($sp) addi $sp, $sp, 4
z=x+y; a.) 2 b.) 6004 c.) 6002 d.) 6008 - 6004 Assume that variables x and y are stored in registers $t0 an $t1, respectively. Which branch statement can be used to convert the following C fragment to assembly? if (x < y) { }
bge $t0, $t1, endif ... endif: b.) ble $t0, $t1, endif ... endif: c.) bgt $t0, $t1, endif ... endif:
d.) blt $t0, $t1, endif ... endif: - a Which MIPSzy brach instruction is the opposite of the ble instruction? a.) bne b.) bge c.) ble d.) bgt - If the base address of an array x is at location 5100, what is the address of x[2]? a.) 5104 b.) 5101 c.) 5108 d.) 5102 - 5108 Which for loop is equivalent to the given while loop? i = 1; while (i <= 5){
... i++; } a.)
addi $t1, $t1, - j end next: addi $t1, $t1, 1 end: sw $t1, 0($t0) a.) if (x>0) x=x+1; else x=x-1; b.) if (x<=0) x=x+1; else x=x+1; c.) if (x>0) x=x+1; else x=x-1; d.) if (x > 0) x=x-1; else x=x+1; -
Assume that variables x and y are in DM[5000] and DM[5004] respectively. Which C statement does the following MIPSzy program implement? addi $t0, $zero, 5000 addi $t1, $zero, 5004 lw $t3, 0($t0) lw $t4, 0($t1) add $t4, $t3, $t add $t3, $t4, $t sw $t3, 0($t0) sw $t4, 0($t1) a.) x=x+y; y=y+y; b.) y=x; c.) y=x+y; x=y+y; d.) x=y; - c Assume that variables x and y are in DM[5000] and DM[5004] respectively. Which C statement does the following assembly program implement?
b.) addi $t1, $zero, 0 top: bge $t0, $zero, end add $t1, $t1, $t addi $t0, $t0, - j top end: c.) addi $t1, $zero, $t top: blt $t0, $zero, end add $t1, $t0, $t addi $t0, $t0, - j top end: d.) addi $t1, $zero, 0 top: blt $t0, $zero, end add $t1, $t1, $t addi $t0, $t0, - j top end: - b
Assume that the address of variables x, y, and z are in registers $t0, $t1, and $t2 respectively. Which of the following assembly programs implements C statement y=x+z? a.) lw $t3, 0($t1) lw $t4, 0($t2) add $t3, $t3, $t sw $t3, 0($t0) b.) lw $t3, 0($t1) lw $t4, 0($t2) add $t4, $t4, $t sw $t4, 0($t3) c.) lw $t2, 0($t1) add $t2, $t2, 2 sw $t2, 0($t0) d.) None of the others - d Assume that the address of variables x and y are in registers $t0 and $t1, respectively. Which of the following assembly programs implements C statement: x=y-2? a.) lw $t2, 0($t1) addi $t2, $t2, - sw $t2, 0($t0)