Microsoft Word Huong dan thuc hanh mips asm tren pcspim doc



tải về 0.57 Mb.
Chế độ xem pdf
trang4/10
Chuyển đổi dữ liệu02.11.2023
Kích0.57 Mb.
#55526
1   2   3   4   5   6   7   8   9   10
huong dan thuc hanh mips asm tren pcspim 5652
MIPSSSS, 5
5. Các chương trình mẫu 
5.1 Các lệnh luận lý:
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 
5.2 Các lệnh số học: 
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 
add 
addu 
div 
multu 
addi 
sub 
divu 
mfhi 
addiu 
subu 
mult 
mflo 
and
ori
nor 
andi 
xor 
sll 
or 
xori 
srl 
## Put the bit pattern 0x0000FACE into register $1. 
.text 
.globl main 
main: 
ori $1,$0,0xFACE # 0x0000FACE into $1 
andi $2,$1,0x0F0F # 0x0A0E in $2 
andi $3,$1,0x00F0 # 0x00C0 in $3 
sll $3,$3,8 # 0xC000 in $3 
or $2,$2,$3 # 0xCA0E in $2 
andi $3,$1,0xF000 # 0xF000 in $3 
srl $3,$3,8 # 0x00F0 in $3 
or $2,$2,$3 # 0xCAFE in $3
# done 
## End of file 


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 



tải về 0.57 Mb.

Chia sẻ với bạn bè của bạn:
1   2   3   4   5   6   7   8   9   10




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương