Академический Документы
Профессиональный Документы
Культура Документы
Notes:op, funct, rd, rs, rt, imm, address, shamt refer to fields in the instruction format. The program counter PC is assumed to
point to the next instruction (usually 4 + the address of the current instruction). M is the byte-addressed main memory.
Instr.
format
op
op/funct
0/32
0/34
0/33
Unsigned, no overflow
0/35
Unsigned, no overflow
Unsigned, no overflow
16
$rt = $rd
0/24
0/25
0/26
0/27
mfhi $rd
0/16
$rd = Hi
Get value of Hi
mflo $rd
0/18
$rd = Lo
Get value of Lo
0/36
Logical AND
0/37
Logical OR
12
13
0/0
0/2
lw $rt, imm($rs)
35
sw $rt, imm($rs)
43
37
sb $rt, imm($rs)
41
15
0/42
10
0/43
11
j destination
PC = address*4
jal destination
jr $rs
0/8
PC = $rs
Assembly instruction
Meaning
Comments
MIPS registers
Name
Number
Usage
$zero
constant 0
$at
$v0 - $v1
2-3
$a0 - $a3
4-7
arguments
$t0 - $t7
8-15
$s0 - $s7
16-23
$t8 - $t9
24-25
$k0 - $k1
26-27
$gp
28
$sp
29
$fp
30
$ra
31
return address
Hi, Lo
PC
contains the address of the next instruction to be fetched (this is not a real
MIPS register, and is only used to define instructions)
status
cause
epc
Bits 31-26
Bits 25-21
Bits 20-16
Bits 15-11
Bits 10-6
Bits 5-0
op
rs
rt
rd
shamt
funct
op
rs
rt
op
imm
address
.asciiz Hello
.text
main:
lw $t0, items($zero)
#
#
#
#
#
#
#
#
#
#
#
#
#
This is a comment
Store following data in the data
segment
This is a label connected to the
next address in the current segment
Stores values 1 and 2 in next two
words
Stores null-terminated string in
memory
Store following instructions in
the text segment
Instruction that uses a label to
address data