CDA3100 Final Study Revised Questions
1.What does the following instruction perform? li $s1,10: Loads the
integer value of 10 into register $s1
2.What is the value of Register $s1 after the following set of
instructions? li $s1,10
addiu $s1,$s1,10: 20
3.What is the difference between the ADD and ADDU instruction?: The
ADDU allows negative numbers but does not check for overflow.
4.Why is there no Subtract Immediate in MIPS?: It would be redundant
because you can add negative immediate numbers using the ADDI or
ADDIU instruction.
5.What is the result of the following Code Segment?
.data
MSG1: .asciiz "Hello World"
.text
.globl main
main: li $v0,4
la $a0,MSG1
syscall
jr $ra: Prints the message Hello World
6.What is the purpose of Line #8?
.data # Line #1
MSG1: .asciiz "Hello World" # Line #2
.text # Line #3
.globl main # Line #4
main: li $v0,4 # Line #5
la $a0,MSG1 # Line #6
syscall # Line #7
jr $ra # Line #8: Returns control to the operating system or stops the
program
7.What is the purpose of Line #6?
.data # Line #1
MSG1: .asciiz "Hello World" # Line #2
.text # Line #3
.globl main # Line #4
main: li $v0,4 # Line #5
la $a0,MSG1 # Line #6
syscall # Line #7
jr $ra # Line #8: Put the address of MSG1 into register $a0
1/
17
,8.What value will be contained in Register $s1 after the following code
seg- ment?
li $s1,10
li $s2,3
div $s1,$s2
mvhi $s1:
1
9.What value will be contained in Register $s1 after the following code
seg- ment?
li $s1,10
li $s2,3
mul $s1,$s1,$s2: 30
10.What is a faster way to multiply and divide using numbers that are
powers of 2?: Shift Left for multiplication, Shift Right for division.
11.Match the service code that is loaded into register $v0 with the
description of the service
(1) : Print Integer
12.Match the service code that is loaded into register $v0 with the
description of the service.
(2) : Print Single Float
13.Match the service code that is loaded into register $v0 with the
description of the service.
(3) : Print Double Float
14.Match the service code that is loaded into register $v0 with the
description of the service.
(4) : Print String
15.Match the service code that is loaded into register $v0 with the
description of the service.
(5) : Read an Integer
16.Match the service code that is loaded into register $v0 with the
description of the service.
(6) : Read a Single Float
17.Match the service code that is loaded into register $v0 with the
description of the service.
2/
17
, (7) : Read a Double Float
3/
17
1.What does the following instruction perform? li $s1,10: Loads the
integer value of 10 into register $s1
2.What is the value of Register $s1 after the following set of
instructions? li $s1,10
addiu $s1,$s1,10: 20
3.What is the difference between the ADD and ADDU instruction?: The
ADDU allows negative numbers but does not check for overflow.
4.Why is there no Subtract Immediate in MIPS?: It would be redundant
because you can add negative immediate numbers using the ADDI or
ADDIU instruction.
5.What is the result of the following Code Segment?
.data
MSG1: .asciiz "Hello World"
.text
.globl main
main: li $v0,4
la $a0,MSG1
syscall
jr $ra: Prints the message Hello World
6.What is the purpose of Line #8?
.data # Line #1
MSG1: .asciiz "Hello World" # Line #2
.text # Line #3
.globl main # Line #4
main: li $v0,4 # Line #5
la $a0,MSG1 # Line #6
syscall # Line #7
jr $ra # Line #8: Returns control to the operating system or stops the
program
7.What is the purpose of Line #6?
.data # Line #1
MSG1: .asciiz "Hello World" # Line #2
.text # Line #3
.globl main # Line #4
main: li $v0,4 # Line #5
la $a0,MSG1 # Line #6
syscall # Line #7
jr $ra # Line #8: Put the address of MSG1 into register $a0
1/
17
,8.What value will be contained in Register $s1 after the following code
seg- ment?
li $s1,10
li $s2,3
div $s1,$s2
mvhi $s1:
1
9.What value will be contained in Register $s1 after the following code
seg- ment?
li $s1,10
li $s2,3
mul $s1,$s1,$s2: 30
10.What is a faster way to multiply and divide using numbers that are
powers of 2?: Shift Left for multiplication, Shift Right for division.
11.Match the service code that is loaded into register $v0 with the
description of the service
(1) : Print Integer
12.Match the service code that is loaded into register $v0 with the
description of the service.
(2) : Print Single Float
13.Match the service code that is loaded into register $v0 with the
description of the service.
(3) : Print Double Float
14.Match the service code that is loaded into register $v0 with the
description of the service.
(4) : Print String
15.Match the service code that is loaded into register $v0 with the
description of the service.
(5) : Read an Integer
16.Match the service code that is loaded into register $v0 with the
description of the service.
(6) : Read a Single Float
17.Match the service code that is loaded into register $v0 with the
description of the service.
2/
17
, (7) : Read a Double Float
3/
17