5.3 Các lệnh thao tác bộ nhớ
Thiết lập các tham số trong menu Simulator -> Settings:
Bare Machine ON, Allow Pseudo Instructions OFF, Load Trap File OFF, Delayed
Branches ON, Delayed Loads ON, Mapped IO OFF, Quiet OFF
lb
lui
sb
lbu
lw
sh
lh
lhu
sw
## Program to calculate 3x**2 + 5x - 8
##
## Assumes that all results fit into 32 bits.
##
## Follows the hardware
rule of keeping a new mult
## two instructions away from a previous mflo.
##
## Register Use:
## $8 x
## $9 result
.text
.globl main
main:
addiu $8, $0, 1 # put x into $8
mult $8, $8 # lo = x**2
mflo $9 # $9 = x**2
ori $7, $0, 3 # $7 = 3
ori $6, $0, 5 # $6 = 5
mult $7, $9 # lo = 3x**2
mflo $9 # $9 = 3x**2
ori $7, $0, 5 # $7 = 5
addi $9, $9, -8 # $9 = 3x**2 - 8
mult $7, $8 # lo = 5x
mflo $7 # $7 = 5x
addu $9, $9, $7 # $9 = 3x**2 + 5x - 8
## End of file