Final Exam
CMPE 012: Computer Systems and Assembly Language
University of California, Santa Cruz
DO NOT BEGIN UNTIL YOU ARE TOLD TO DO SO.
This exam is closed book and closed notes. Only 4-function calculators are permitted. Answers must be marked on the Scantron form to be graded. All work must be written on the exam.
On the Scantron form, bubble in your name, student ID number, and test form (found in the footer of subsequent pages). In the center of the page write your CruzID, quarter, and exam type. On the back of the page, write the CruzIDs of students sitting to your left and right, and your row and seat number. See below.
On this page, write your last name, first name, CruzID, row and seat numbers, and the CruzIDs of the people to your immediate left and right. Once you are permitted to begin, write your CruzID on all subsequent pages of the exam.
You must sit in your assigned seat. Keep your student or government issued ID on your desk. Brimmed hats must be removed or turned around backwards. Only unmarked water bottles are permitted. Backpacks must be placed at the front of the room or along the walls. Your cell phone must be on a setting where it will not make noise or vibrate.
There are 42 questions on this exam; you only need to answer 40 for full points. The additional two questions (of your choosing) will be counted as extra credit. All questions are multiple choice, and some questions have more than one correct answer. You must mark all correct answers to receive credit for a question. Some true/false questions might list False as answer A and True as answer B. Follow the answers on the exam, NOT the T F notation on the Scantron Form. You will have 120 minutes to complete this exam.
____________________________ ____________________________ ____________________________
Row # Seat #
___________________________________________ Your Last Name
___________________________________________ CruzID of person to left
CruzID
___________________________________________ Your First Name
___________________________________________ CruzID of person to right
CMPE 12 Final – Version A Spring 2019
Combinational Logic & Boolean Algebra
1. True or False: These two circuits are logically equivalent.
⃝ A. True ⃝ B. False
2. Select the Boolean expression(s) matching the grey filled areas of this Venn diagram.
CruzID:
@ucsc.edu
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
SCF+S ̄CF ̄+SC ̄F+S ̄C ̄F SCF+C ̄F+S ̄CF ̄ S ̄C ̄F ̄+SF ̄+S ̄FC
Correct answer not listed S ̄C ̄F ̄+S ̄F+SF ̄C+CF
Page 1 of 15
3. Which circuit matches this truth table?
CruzID: @ucsc.edu
A
B
C
D
0
0
0
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
Page 2 of 15
4. What kind of multiplexor has 3 select lines? ⃝ A. 3-to-1
⃝ B. 2-to-1 ⃝ C. 16-to-1 ⃝ D. 8-to-1 ⃝ E. 9-to-1
5. What equation does this PLA represent?
⃝ A. (A ̄+B+C)(A+B ̄+C ̄)(A+B+C)(A ̄+B ̄+C ̄) ⃝ B. (A ̄+B ̄+C ̄)(A+B+C ̄)(A ̄+B+C ̄)(A ̄+B ̄+C) ⃝ C. (A ̄+B ̄+C)(A ̄+B+C ̄)(A+B ̄+C ̄)(A+B ̄+C) ⃝ D. (A+B+C)(A+B ̄+C ̄)(A ̄+B+C ̄)(A ̄+B ̄+C) ⃝ E. (A+B+C)(A ̄+B+C)(A+B ̄+C)(A+B+C ̄)
Sequential Logic
6. What
device does this timing diagram represent?
CruzID: @ucsc.edu
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
D flip flop, edge triggered D-Rlatch
D latch, level triggered S-R latch, active high S-R latch, active low
Page 3 of 15
7. Which of the following circuits can form a latch?
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
CruzID: @ucsc.edu
Page 4 of 15
Integers
8. What is 12304 in base 32? Assume A32 = 10, B32 = 11, … , G32 = 16, etc.
⃝ A. 3C32
⃝ B. 3D32
⃝ C. BT32
⃝ D. 3C032
⃝ E. 4D32
⃝ B.
⃝ C.
⃝ D.
⃝ E.
9. What ⃝ A.
is the range of values for an integer in 8-bit sign-magnitude representation? -127 to 128
-127 to 127 0to255 -128 to 127 -128 to 128
10. Extendthefollowing4-bitsign-magnitudevalueto8-bits:0b1101 ⃝ A. 0b11111101
⃝ B. 0b00001101 ⃝ C. 0b10001101 ⃝ D. 0b10000101 ⃝ E. 0b00001101
11. Whatisthedecimalequivalentofthe8-bittwo’scomplementnumber0b10010111? ⃝ A. -105
⃝ B. -151 ⃝ C. 151 ⃝ D. 105 ⃝ E. -104
12. Convert2103tobase5. ⃝ A. 215
⃝ B. 4110 ⃝ C. 2105 ⃝ D. 2115 ⃝ E. 415
13. Whatisthelowestnumberthatcanberepresentedusing8-bitbias127representation? ⃝ A. 127
⃝ B. -127 ⃝ C. -256 ⃝ D. 0
⃝ E. -128
14. Convertthe8-bittwo’scomplementnumber0b11001101to8-bitsign-magnituderepresentation. ⃝ A. 0b11001100
⃝ B. 0b01001100 ⃝ C. 0b00110011 ⃝ D. 0b01001101 ⃝ E. 0b10110011
Page 5 of 15
CruzID:
@ucsc.edu
CruzID:
@ucsc.edu
15. Whatisthelargestunsignedintegera6-bitregistercanhold? ⃝ A. 0x8
⃝ B. 0xF ⃝ C. 0xFF ⃝ D. 0xFFF ⃝ E. 0x3F
Fractions & Floating Point
16. WhichIEEE754singleprecisionfloatingpointnumberisfurthestfromzero? ⃝ A. 0x4479C000
⃝ B. 0xC47A0000 ⃝ C. 0x41300000 ⃝ D. 0xC25C0000 ⃝ E. 0x431B0000
17. Convertthedecimalvalue51.810tounsignedfractionalbinary ⃝ A. 110011.1100
⃝ B. 110011.0001 ⃝ C. 110011.1000 ⃝ D. 110011.1100 ⃝ E. 110011.0001
18. WhichIEEE754singleprecisionfloatingpointnumberhasthelargestpositiveexponent? ⃝ A. 0x42903333
⃝ B. 0x43F7999A ⃝ C. 0xC3018000 ⃝ D. 0xC2366666 ⃝ E. 0x425A6666
19. Convertthefloatingpointnumber0x40400000tounsignedbinary. ⃝ A. 0b101
⃝ B. 0b001 ⃝ C. 0b011 ⃝ D. 0b110 ⃝ E. 0b010
Page 6 of 15
Strings
20. WhatisprintedtothescreeninthisMIPSprogram?
.data
P1: .space 27
P2: .asciiz “ABCDEFGHIJKLMNOPQRSTUZWXYZ”
.text
L1: la $t0, P1
addi $t1, $zero, 26
addi $t2, $zero, 97
L2: sb $t2, ($t0)
addi $t1, $t1, -1
beqz $t1, GLUE
addi $t0, $t0, 1
addi $t2, $t2, 1
b L2
GLUE: li $v0, 4
la $a0, P1
syscall
li $v0, 10
syscall
# ascii value for ’a’
# increment address
# increment ascii value
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUZWXYZ
Correct answer not listed; runtime error abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUZWXYZ 27
21. DecodethefollowingASCIIstring.Valuesaregiveninhex:
49 20 68 61 76 65 20 74 68 65 20 68 69 67 68 20 67 72 6f 75 6e 64 21.
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
I have the high ground!
I have no idea what the other sentences mean. It’s over Anakin!
You underestimate my power!
Don’t try it.
Page 7 of 15
CruzID:
@ucsc.edu
Arithmetic & Logical Operations
22. Whatistheresultofabit-wiseXORperformedonthefollowing8-bitbinarynumbers:
0b 1 0 1 1 0 1 1 0 ⊕0b 1 0 1 0 1 0 1 0 ————————————
⃝ A. 0b01000001 ⃝ B. 0b00011100 ⃝ C. 0b10111110 ⃝ D. 0b11100011 ⃝ E. 0b10100010
23. What is the result of a shift right arithmetic by three and a shift right logical by three of the 8-bit number 10010110 = 0x96? The operations are performed independently of each other.
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
0x12 and 0x12 0xB0 and 0xB7 0x12 and 0xF2 0xB7 and 0xB0 0xF2 and 0x12
24. Whichofthese8-bittwo’scomplementcomputationshascarryoutbutnooverflow?Selectallthatapply. ⃝ A. 0x80 + 0x80 = 0x00
⃝ B. 0xFB + 0xCC = 0xC7
⃝ C. 0x7F + 0x70 = 0xEF
⃝ D. 0x89 + 0xFF = 0x88 ⃝ E. 0xA7 + 0x61 = 0x08
Memory
25. Assumealittleendianmemorysystem.Whatisstoredin$s0afterthefollowingprogramisexecuted?
.data
flux: .word 0xC0FFEEEE
some_data: .byte 0xFE 0xED 0xBB
some_more_data: .byte 0xCE
.text
la $t1 some_more_data
lw $t0 ($t1)
sb $t0 2($t1)
lw $s0 ($t1)
1 2 0x00
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
0x00CE01CE
0x000200CE
Answer not listed; memory alignment error 0xCE010000
0xCE01CE00
Page 8 of 15
CruzID:
@ucsc.edu
CruzID: @ucsc.edu
26. Howmanybitsareneededtorepresenttheaddressinabyte-addressablememoryspacewithcapacityof5TB?
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
43
Correct answer not listed 33
20
40
27. Howmany32-bitintegerscanbestoredinthearraylabeledmyArrayasshownbelow: .data
msg: .asciiz “Good luck!!”
myArray: .space 20
tacos:
⃝ A. 80 ⃝ B. 5 ⃝ C. 4 ⃝ D. 10 ⃝ E. 2.5
MIPS Instruction Set Architecture
28. Howcanwecreateamaskforbits4:14of$t0? ⃝ A. andi $t0 $t0 0x7ff0
⃝ B. andi $t0 $t0 0x800f
⃝ C. ori $t0 $t0 0x800f
⃝ D. ori $t0 $t0 0x7ff0 ⃝ E. xori $t0 $t0 0x7ff0
29. Whatisthevaluein$10afterthefollowinginstructionsareexecuted? ADDI $10 $0 11
SLL SRL
⃝ ⃝ ⃝ ⃝ ⃝
$10 $10 30
$10 $10 29
A. 0xFFFE B. 0xFFFF C. 0x000B D. 0x000F E. 0x000E
.asciiz “Tacos and 2SC make me happy!!”
30. DecodethefollowingMIPSinstruction.Selectallthatapply.
0x8D090008
⃝ A. sw $8 8($9) ⃝B.addi$8 $9 8
⃝ C. lw ⃝ D. sw ⃝ E. lw
$t1 8($t0)
$t1 8($t0)
$t0 8($t1)
Page 9 of 15
CruzID: @ucsc.edu 31. Assume$s0=0x6and$t7=0xA.Whatvalueisstoredin$t7afterthefollowinginstruction?
div $t7 $s0
⃝ A. 0x1 ⃝ B. 0x6 ⃝ C. 0x4 ⃝ D. 0x0 ⃝ E. 0xA
32. DecodethefollowingMIPSinstruction.Selectallthatapply.
0x012F4020
⃝ A. ADD $8 ⃝B. AND$9 ⃝ C. ADD $t1 ⃝ D. ADD $t0 ⃝E. ADD$9
$9 $15
$15 $8
$t7 $t0
$t1 $t7
$15 $8
33. WhatisthesizeofaregisterinMIPS32?Selectallthatapply. ⃝ A. 64bits
⃝ B. 8bytes ⃝ C. 32bits ⃝ D. 8nybbles ⃝ E. 4bytes
34. Whatisthevaluein$t0afterthefollowinginstructionsareexecuted?
li $t0, 5
li $t1, 10
xor $t0, $t0, $t0
loop: nop
addi $t0, $t0, 1
subi $t1, $t1, 1
bgtz $t1, loop
li $v0, 10
syscall
⃝ A. 16 ⃝ B. 15 ⃝ C. 10 ⃝ D. 5 ⃝ E. 0
Page 10 of 15
CruzID: @ucsc.edu 35. Whatisthevalueofregister$v0afterthefollowinginstructions?
addi $t1 $zero 8
addi $s0 $zero 50
addi $v0 $zero 0
loop: nop
andi $a0 $s0 0
add $v0 $v0 $a0
srl $t1 $t1 1
bnez $t1 loop
⃝ A. 2
⃝ B. 20
⃝ C. 18
⃝ D. 0
⃝ E. 50
# 50 = 0b110010
Page 11 of 15
CruzID: @ucsc.edu
Stack & Subroutines
36. Whichinstructionwilltheprogramcounterpointtoafterthe“jr$ra”instructionexecutesinthePromptuser subroutine?
.data
P1: .asciiz “Input: ”
N1: .word
.text
la $a0, P1
la $a1, N1
jal Prompt_user
halt: li $v0, 10
syscall
PrintString:
li $v0, 4
syscall
jr $ra
Prompt_user:
jal PrintString
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
move $a0, $a1
li $v0, 8
syscall
jr $ra
jal Prompt user
jal PrintString
move $a0, $a1
Answer not listed; code doesn’t assemble halt: li $v0, 10
Page 12 of 15
37. Which combination of MIPS instructions perform a push operation of two elements (in $t0 and $t1) on the stack? Select all that apply.
⃝ A. sw $t0, ($sp) sw $t1, 4($sp)
subi $sp,
subi $sp,
sw $t0,
sw $t1, 4($sp)
⃝B. ⃝C.
⃝ D. lw
lw $t1,
addi $sp, ⃝E. addi $sp, lw $t0, addi $sp, lw $t1,
$sp, 8 ($sp)
subi $sp,
sw $t0,
subi $sp,
sw $t1, ($sp)
$sp, 8
$sp, 4 ($sp)
$sp, 4
$t0, ($sp)
($sp)
$sp, 8
$sp, 4
($sp) $sp, 4
($sp)
Page 13 of 15
CruzID: @ucsc.edu
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
0x0B0C
0x10
Not enough information given. 0x02C3
0x11
40. Assumethevaluesonwires’1’,’5’,’10’,’11’and’12’are0x08,0x10,0xAF,0xBEand0xBErespectively. Which instruction could correspond to these values?
⃝ A.
⃝ B.
⃝ C.
⃝ D. LH $7 10($8)
⃝ E.
Not enough information given.
LW $s0 16($s0)
ADDI $t0 $t0 0x10
LB $t1 16($t0)
Page 14 of 15
CruzID: @ucsc.edu
Data Path
Refer to this MIPS data path for the next three questions:
38. Assume$s0=0xAB,$s1=0x11andSH $s1 8($s0)isexecuted.Whatisthevalueonwire’8’?
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
Not enough information given.
0x11
0xAB
0x08
0x10
39. Assumeinstruction0x150802C3isexecuted.Whatisthevalueonwire’4’?
Command Line Interface
41. TrueorFalse:Listingthefilesofadifferentdirectorychangesthedirectoryyouarein. ⃝ A. False
⃝ B. True
42. TrueorFalse:Thecommand’mv’canbeusedtorenameafile. ⃝ A. True
⃝ B. False
Page 15 of 15
CruzID:
@ucsc.edu
REG NAME REG # MNEMONIC MEANING
TYPE OPCODE FUNCT MNEMONIC MEANING
TYPE OPCODE FUNCT
$zero 0 sll $at 1 srl
$v0 2 sra
$v1 3 jr
$a0 4 mfhi
$a1 5 mflo
$a2 6 mult
$a3 7 multu
$t0 8 div
$t1 9 divu
$t2 10 add
$t3 11 addu
$t4 12 sub
$t5 13 subu
$t6 14 and
$t7 15 or
$s0 16 xor
$s1 17 nor
$s2 18 slt
$s3 19 sltu
$s4 20 j
$s5 21 jal
$s6 22 beq
$s7 23 bne
$t8 24 blez
$t9 25 addi
$k0 26 addiu
$k1 27 slti
$gp 28 sltiu $sp 29 andi
xori Bitwise XOR (Exclusive-OR) Immediate lui Load Upper Immediate
mfc0 Move from Coprocessor 0
lb Load Byte
lh Load Halfword
lw Load Word
lbu Load Byte Unsigned
lhu Load Halfword Unsigned sb Store Byte
sh Store Halfword
sw Store Word
Logical Shift Left
Logical Shift Right (0-extended) Arithmetic Shift Right (sign-extended) Jump to Address in Register
Move from HI Register
Move from LO Register
Multiply
Unsigned
Divide
Unsigned
Add
Add Unsigned
Subtract
Unsigned Subtract
Bitwise AND
Bitwise OR
Bitwise XOR
Bitwise NOR
Setto1if
Setto1if
Jump to Address
Jump and Link
Branch if Equal
Branch if Not Equal
Branch if Less Than or Equal to Zero
Add Immediate
Add Unsigned Immediate
Set to 1 if Less Than Immediate
Set to 1 if Less Than Unsigned ImmediateI
0x00 0x00 add 0x00 0x02 addi 0x00 0x03 addiu 0x00 0x08 addu 0x00 0x10 and 0x00 0x12 andi 0x00 0x18 beq 0x00 0x19 blez 0x00 0x1A bne 0x00 0x1B div 0x00 0x20 divu 0x00 0x21 j 0x00 0x22 jal 0x00 0x23 jr 0x00 0x24 lb 0x00 0x25 lbu 0x00 0x26 lh 0x00 0x27 lhu 0x00 0x2A lui 0x00 0x2B lw 0x02 NA mfc0 0x03 NA mfhi 0x04 NA mflo 0x05 NA mult 0x06 NA multu 0x08 NA nor 0x09 NA or 0x0A NA ori 0x0B NA sb 0x0C NA sh 0x0D NA sll 0x0E NA slt 0x0F NA slti 0x10 NA sltiu 0x20 NA sltu 0x21 NA sra 0x23 NA srl 0x24 NA sub 0x25 NA subu 0x28 NA sw 0x29 NA xor 0x2B NA xori
Add
Add Immediate
Add Unsigned Immediate
Add Unsigned
Bitwise AND
Bitwise AND Immediate
R
I
I
R
R
I
I
I
I
R
R
J
J
R
I
I
I
I
I
I
R
R
R
R
R
R
R
I
I
I
R
R
I
0x00 0x20 0x08 NA 0x09 NA 0x00 0x21 0x00 0x24 0x0C NA 0x04 NA 0x06 NA 0x05 NA 0x00 0x1A 0x00 0x1B 0x02 NA 0x03 NA 0x00 0x08 0x20 NA 0x24 NA 0x21 NA 0x25 NA 0x0F NA 0x23 NA 0x10 NA 0x00 0x10 0x00 0x12 0x00 0x18 0x00 0x19 0x00 0x27 0x00 0x25 0x0D NA 0x28 NA 0x29 NA 0x00 0x00 0x00 0x2A 0x0A NA 0x0B NA 0x00 0x2B 0x00 0x03 0x00 0x02 0x00 0x22 0x00 0x23 0x2B NA 0x00 0x26 0x0E NA
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
R
J
J
I
I
I
I
I
I
Branch
Branch
Branch
Divide
Unsigned Divide
Jump to Address
Jump and Link
Jump to Address in Register
Load Byte
Multiply
Divide
if Equal
if Less Than or Equal to Zero
if Not Equal
(Exclusive-OR)
(NOT-OR)
Less Than
Less Than Unsigned
Load Byte Unsigned
Load Halfword
Load Halfword Unsigned
Load Upper Immediate
Load Word
Move from
Move from
Move from
Multiply
Unsigned Multiply
Bitwise NOR (NOT-OR)
Bitwise OR
Bitwise OR Immediate
0
Coprocessor
HI Register
LO Register
Bitwise AND Immediate ori Bitwise OR Immediate
I
I
I
I
R
I
I
I
I
I
I
I
I
Store Byte
Store Halfword
Logical Shift Left
Set to 1 if Less Than
Set to 1 if Less Than
Set to 1 if Less Than
Set to 1 if Less Than
Arithmetic Shift Right (sign-extended)
Logical Shift Right (0-extended)
Subtract
Unsigned Subtract
Store Word
Bitwise XOR (Exclusive-OR)
Bitwise XOR (Exclusive-OR) Immediate
Immediate
Unsigned Immediate I
Unsigned
R R R R R I R I
R Type: instr rd rs rt (arithmetic, logical)
instr rd rt shamt (shifts)
31
26
25
21
20
16
15
11
10
6
5
0
<- 6 bits ->
<- 5 bits ->
<- 5 bits ->
<- 5 bits ->
<- 5 bits ->
<- 6 bits ->
opcode
rs
rt
rd
shamt
funct
I Type: instr rt rs immediate
branch rs rt immediate
instr rt immediate(rs)
(arithmetic, logical)
(branches)
(loads, stores)
31
26
25
21
20
16
15
0
<- 6 bits ->
<- 5 bits ->
<- 5 bits ->
<- 16 bits ->
opcode
rs
rt
immediate
J Type: j immediate (jumps)
31
26
25
0
<- 6 bits ->
<- 26 bits ->
opcode
immediate
ASCII CODE
BIN OCT DEC HEX CHARACTER
ASCII CODE
OCT DEC HEX CHARACTER
ASCII CODE
OCT DEC HEX CHARACTER
–
ASCII CODE
OCT DEC HEX CHARACTER
150 104 68 h 151 105 69 i 152 106 6A j 153 107 6B k 154 108 6C l 155 109 6D m 156 110 6E n 157 111 6F o 160 112 70 p 161 113 71 q 162 114 72 r 163 115 73 s 164 116 74 t 165 117 75 u 166 118 76 v 167 119 77 w 170 120 78 x 171 121 79 y 172 122 7A z 173 123 7B { 174 124 7C | 175 125 7D } 178 126 7E ~ 177 127 7F DEL
010 0000 40 32 20 010 0001 41 33 21 010 0010 42 34 22 010 0011 43 35 23 010 0100 44 36 24 010 0101 45 37 25 010 0110 46 38 26 010 0111 47 39 27 010 1000 50 40 28 010 1001 51 41 29 010 1010 52 42 2A 010 1011 53 43 2B 010 1100 54 44 2C 010 1101 55 45 2D 010 1110 56 46 2E 010 1111 57 47 2F 011 0000 60 48 30 011 0001 61 49 31 011 0010 62 50 32 011 0011 63 51 33 011 0100 64 52 34 011 0101 65 53 35 011 0110 66 54 36 011 0111 67 55 37
Note: ASCII
BIN
space 011 1000
705638 715739 72583A 73593B 74603C 75613D 76623E 77633F
100 64 40 101 65 41 102 66 42 103 67 43 104 68 44 105 69 45 106 70 46 107 71 47 110 72 48 111 73 49 112 74 4A 113 75 4B 114 76 4C 115 77 4D 116 78 4E 117 79 4F
BIN
8 101 0000
120 80 50 121 81 51 122 82 52 123 83 53 124 84 54 125 85 55 126 86 56 127 87 57 130 88 58 131 89 59 132 90 5A 133 91 5B 134 92 5C 135 93 5D 136 94 5E 137 95 5F 140 96 60 141 97 61 142 98 62 143 99 63 144 100 64 145 101 65 146 102 66 147 103 67
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
`
a
b
c
d
e
f
g
BIN
110 1000 110 1001 110 1010 110 1011 110 1100 110 1101 110 1110 110 1111 111 0000 111 0001 111 0010 111 0011 111 0100 111 0101 111 0110 111 0111 111 1000 111 1001 111 1010 111 1011 111 1100 111 1101 111 1110 111 1111
! 011 1001 ” 011 1010 # 011 1011 $ 011 1100 % 011 1101 & 011 1110 ‘ 011 1111 ( 100 0000 ) 100 0001 * 100 0010 + 100 0011 , 100 0100 – 100 0101 . 100 0110 / 100 0111 0 100 1000 1 100 1001 2 100 1010 3 100 1011 4 100 1100 5 100 1101 6 100 1110 7 100 1111
9 101 0001 : 101 0010 ; 101 0011 < 101 0100 = 101 0101 > 101 0110 ? 101 0111 @ 101 1000 A 101 1001 B 101 1010 C 101 1011 D 101 1100 E 101 1101 F 101 1110 G 101 1111 H 110 0000 I 110 0001 J 110 0010 K 110 0011 L 110 0100 M 110 0101 N 110 0110 O 110 0111
codes 0x00 -> 0x1F are unprintable control characters used to control peripherals (e.g. printers)
CODE IN $v0
ARGUMENTS
1
$a0 = integer to print
2
$f12 = float to print
3
$f12 = double to print
4
$a0 = address of null-terminated string to
print
5
6
7
8
$a0 = address of input buffer
$a1 = maximum number of characters to read
9
$a0 = number of bytes to allocate
10
11
$a0 = character to print
12
13
$a0 = address of null-terminated string
containing filename
$a1 = flags
$a2 = mode
14
$a0 = file descriptor
$a1 = address of input buffer
$a2 = maximum number of characters to read
15
$a0 = file descriptor
$a1 = address of output buffer
$a2 = number of characters to write
16
$a0 = file descriptor
17
$a0 = termination result
SERVICE
print integer
print float
print double
RESULT
print string
read integer $v0 contains integer read read float $f0 contains float read read double $f0 contains double read
read string
sbrk
(allocate
heap memory)
exit
(terminate
execution)
print
character
read
character
open file
read from
file
write to file
close file
exit2
(terminate
with value)
See note below table
$v0 contains address of allocated
memory
See note below table
$v0 contains character read
$v0 contains file descriptor (negative
if error). See note below table
$v0 contains number of characters read
(0 if end-of-file, negative if error).
See note below table
$v0 contains number of characters
written (negative if error). See note
below table
See note below table
Services 1 through 17 are compatible with the SPIM simulator, other than Open File (13) as described in the Notes below the table. Services 30 and higher are exclusive to MARS.
30
31
$a0 = pitch (0-127)
$a1 = duration in milliseconds
$a2 = instrument (0-127)
$a3 = volume (0-127)
32
$a0 = the length of time to sleep in
milliseconds.
33
$a0 = pitch (0-127)
$a1 = duration in milliseconds
$a2 = instrument (0-127)
$a3 = volume (0-127)
34
$a0 = integer to print
35
$a0 = integer to print
36
$a0 = integer to print
time (system
time)
MIDI out
sleep
MIDI out
synchronous
print integer
in
hexadecimal
print integer
in binary
print integer
as unsigned
$a0 = low order 32 bits of system time
$a1 = high order 32 bits of system
time. See note below table
Generate tone and return immediately.
See note below table
Causes the MARS Java thread to sleep
for (at least) the specified number of
milliseconds. This timing will not be
precise, as the Java implementation
will add some overhead.
Generate tone and return upon tone
completion. See note below table
Displayed value is 8 hexadecimal
digits, left-padding with zeroes if
necessary.
Displayed value is 32 bits, left-
padding with zeroes if necessary.
Displayed as unsigned decimal value.