Module 6 - Assembly Programming Flashcards

1
Q

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.

A

Copy data from a register to another register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
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
A

sw $t0, 4($s1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What is the smallest unit of memory data that is addressable (has an address) in MIPS architecture?
  double-word
  byte
  word
  bit
A

byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
The MIPS architecture uses a general-purpose register file with how many entries?
  32
  64
  16
  Up to 4GB
  8
  4
A

32

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
The MIPS architecture uses a general-purpose register file and each entry stores how many bits?
  Up to 4GB
  32
  64
  4
  16
  8
A

32

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

55808

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

66

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Which of the following keywords is the MIPS instruction for “add signed”?
  add
  and
  addi
  addu
A

add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

beq $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s1, $s0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A
beq $s0, $s1, Else
add $s2, $s0, $s1
j Next
Else: sub $s1, $s1, $s0
Next: addi $s0, $s0, 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Which of the following instructions should be used to implement an "if (a!=b)" decision in assembly?
  bgtz
  j
  beq
  bne
  blez
A

beq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
Which of the following instructions should is used to implement a decision in assembly that has an else component?
  j
  beq
  bgtz
  bne
  blez
A

j

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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
A

bne $s0, $s1, Lab1
add $s2, $s0, $s1
Lab1: sub $s1, $s0, $s1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Given variables i and j stored in $s0 and $s1 respectively, which of the following assembly blocks implements if(i > j) ?

slt $t0, $s1, $s0
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

slt $t0, $s0, $s1
bne $t0, $zero, Next

slt $t0, $s0, $s1
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

slt $t0, $s1, $s0
bne $t0, $zero, Next

A

slt $t0, $s1, $s0
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

17
Q

Given variables i and j stored in $s0 and $s1 respectively, select the decision that matches the following assembly code:

slt $t0, $s1, $s0
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

if (i < j )
if ( i > j )
if (i <= j )
if ( i >= j )

A

if ( i > j )

18
Q

Given variables i and j stored in $s0 and $s1 respectively, which of the following assembly blocks implements if(i >= j) ?

slt $t0, $s0, $s1
bne $t0, $zero, Next

slt $t0, $s1, $s0
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

slt $t0, $s0, $s1
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

slt $t0, $s1, $s0
bne $t0, $zero, Next

A

slt $t0, $s0, $s1

bne $t0, $zero, Next

19
Q

Given variables i and j stored in $s0 and $s1 respectively, which of the following assembly blocks implements if(i < j) ?

slt $t0, $s0, $s1
bne $t0, $zero, Next

slt $t0, $s1, $s0
bne $t0, $zero, Next

slt $t0, $s1, $s0
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

slt $t0, $s0, $s1
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

A

slt $t0, $s0, $s1
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

20
Q

Given variables i and j stored in $s0 and $s1 respectively, select the decision that matches the following assembly code:

slt $t0, $s0, $s1
ori $at, $zero, 1
subu $t0, $at, $t0
bne $t0, $zero, Next

if (i < j )
if ( i > j )
if (i <= j )
if ( i >= j )

A

if (i < j )

21
Q

Select the primary difference between the implementation of a while statement, and the implementation of an for statement in assembly:

The jump points to a label further down in the program.
The jump points to a label at or before the branch.
An incrementing or decrementing statement is placed before the jump, to update the sentinel variable.
No difference.

A

An incrementing or decrementing statement is placed before the jump, to update the sentinel variable.

22
Q

Select the primary difference between the implementation of a while statement, and the implementation of an if-else statement in assembly:

An incrementing or decrementing statement is placed before the jump, to update the sentinel variable.
The jump points to a label further down in the program.
No difference.
The jump points to a label at or before the branch

A

The jump points to a label at or before the branch