Module 6 - Assembly Programming Flashcards
An add $t0, $t1, $zero instruction can be used to:
Copy data from main memory to a register.
Copy data from a register to main memory
Copy data from main memory to another location in main memory.
Copy data from a register to another register.
Copy data from a register to another register.
Which of the following instructions can be used to copy data from a register to main memory? lw $t0, 4($s1) sw $t0, 4($s1) add $t0, $t1, $zero sll $s0, $t1, 4
sw $t0, 4($s1)
What is the smallest unit of memory data that is addressable (has an address) in MIPS architecture? double-word byte word bit
byte
The MIPS architecture uses a general-purpose register file with how many entries? 32 64 16 Up to 4GB 8 4
32
The MIPS architecture uses a general-purpose register file and each entry stores how many bits? Up to 4GB 32 64 4 16 8
32
In the field below, enter the integer value of the $v0 register after executing the following instruction, given the register values $zero = 0, $t7 = 109 :
sll $v0, $t7, 9
55808
In the field below, enter the integer value of the $v0 register after executing the following instruction, given the register values $zero = 0 :
andi $v0, $zero, 5428
0
In the field below, enter the integer value of the $v0 register after executing the following instruction, given the register values $t0 = 31, $t7 = 93 :
xor $v0, $t0, $t7
66
Which of the following keywords is the MIPS instruction for “add signed”? add and addi addu
add
In the field below, enter the integer value of the $v0 register after executing the following instruction, given the register values $s4 = 44 :
andi $v0, $s4, 17100
12
Select the correct MIPS assembly implementation of the following C code decision (given i,j,k stored in $s0, $s1 and $s2 respectively:
if (i!=j)
k = i+j;
j = j-i
beq $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s1, $s0
bne $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s2, $s2, $s0 Next: addi $s2, $s2, 1
beq $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s2, $s2, $s0 Next: addi $s2, $s2, 1
bne $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1
beq $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s1, $s0
Select the correct MIPS assembly implementation of the following C code decision (given i,j,k stored in $s0, $s1 and $s2 respectively:
if (i!=j) k = i+j; else j = j-i; i = i+1;
bne $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s1, $s1, $s0 Next: addi $s0, $s0, 1
beq $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1
beq $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s1, $s1, $s0 Next: addi $s0, $s0, 1
bne $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1
beq $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s1, $s1, $s0 Next: addi $s0, $s0, 1
Which of the following instructions should be used to implement an "if (a!=b)" decision in assembly? bgtz j beq bne blez
beq
Which of the following instructions should is used to implement a decision in assembly that has an else component? j beq bgtz bne blez
j
Select the correct MIPS assembly implementation of the following C code decision (given i,j,k stored in $s0, $s1 and $s2 respectively:
if (i==j)
k = i+j;
j = j-i
bne $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s2, $s2, $s0 Next: addi $s2, $s2, 1
bne $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1
beq $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1
beq $s0, $s1, Else add $s2, $s0, $s1 j Next Else: sub $s2, $s2, $s0 Next: addi $s2, $s2, 1
bne $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1