type
status
slug
summary
tags
category
password
date
icon
计算机组成这门课程对我来说十分tricky
因此在期中考试之前开始急急急了
目标:面向期中考试和期末考试
📝 期中考试
需要注意的是⚠️:
其中 "preserved on call" 的意思是,是否保证调用前后这些寄存器的值不变。
trans:
addi sp,sp,-48
sd s0,40(sp)
addi s0,sp,48
sd a0,-40(s0)
sw zero,-28(s0)
j .L2
.L5:
sw zero,-24(s0)
j .L3
.L4:
lw a4,-28(s0)
mv a5,a4
slli a5,a5,2
add a5,a5,a4
slli a5,a5,3
mv a4,a5
ld a5,-40(s0)
add a4,a5,a4
lw a5,-24(s0)
slli a5,a5,2
add a5,a4,a5
lw a5,0(a5)
sw a5,-20(s0)
lw a4,-24(s0)
mv a5,a4
slli a5,a5,2
add a5,a5,a4
slli a5,a5,3
mv a4,a5
ld a5,-40(s0)
add a2,a5,a4
lw a4,-28(s0)
mv a5,a4
slli a5,a5,2
add a5,a5,a4
slli a5,a5,3
mv a4,a5
ld a5,-40(s0)
add a3,a5,a4
lw a5,-28(s0)
slli a5,a5,2
add a5,a2,a5
lw a4,0(a5)
lw a5,-24(s0)
slli a5,a5,2
add a5,a3,a5
sw a4,0(a5)
lw a4,-24(s0)
mv a5,a4
slli a5,a5,2
add a5,a5,a4
slli a5,a5,3
mv a4,a5
ld a5,-40(s0)
add a4,a5,a4
lw a5,-28(s0)
slli a5,a5,2
add a5,a4,a5
lw a4,-20(s0)
sw a4,0(a5)
lw a5,-24(s0)
addiw a5,a5,1
sw a5,-24(s0)
.L3:
lw a5,-24(s0)
sext.w a4,a5
li a5,9
ble a4,a5,.L4
lw a5,-28(s0)
addiw a5,a5,1
sw a5,-28(s0)
.L2:
lw a5,-28(s0)
sext.w a4,a5
li a5,9
ble a4,a5,.L5
nop
nop
ld s0,40(sp)
addi sp,sp,48
jr ra
.size trans, .-trans
.ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
.section .note.GNU-stack,"",@progbits
- 作者:fufu酱
- 链接:https://csfufu.life/article/58dd7e69-4fe8-4936-948d-5eb7e492f78e
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章