# name :
# EE:361, DATE
.data
msga : .asciiz "enter number a:/n"
msgb : .asciiz "enter number b:/n"
msg : .asciiz "the product is : "
.text
.globl main
.globl mymul
main :
addi $sp , $sp ,-8
sw $ra ,4($sp)
sw $fp ,0($sp)
la $a0, msg
li $v1,4
syscall
li $v1,5
syscall
add $s1 , $v1 , $0
la $a0,msgb
li $v1, 4
syscall
li $v1,5
syscall
add $a1 ,$v1 ,$0
add $a0,$1,$0
add $fp,$sp,$0
jal mymul
add $1,$v1,$0
la $a0 ,msg
li $v1,4
syscall
add $a0 ,$1,$0
li $v1,1
syscall
lw $fp ,0($sp)
lw $ra,4($sp)
addi $sp,$sp,8
li $v1, 10
syscall
mymul:
addi $sp ,$sp ,-4
sw $s0,0($sp)
add $s0 , $a1 ,$0
add $v1 ,$0, $0
beq $s0 , $0, multEol
add $v1,$v1,$a0
addi $s0,$s0,-1
j multloop
multEol:
lw $s0,0($sp)
jr $ra
我编写了以下代码,但是它不起作用,并且没有o / p
我使用称为火星的mips模拟器
.data
msga : .asciiz "enter number a:/n"
msgb : .asciiz "enter number b:/n"
msg : .asciiz "the product is : "
.text
.globl main
.globl mymul
main :
addi $sp , $sp ,-8
sw $ra ,4($sp)
sw $fp ,0($sp)
la $a0, msg
li $v1,4
syscall
li $v1,5
syscall
add $s1 , $v1 , $0
la $a0,msgb
li $v1, 4
syscall
li $v1,5
syscall
add $a1 ,$v1 ,$0
add $a0,$1,$0
add $fp,$sp,$0
jal mymul
add $1,$v1,$0
la $a0 ,msg
li $v1,4
syscall
add $a0 ,$1,$0
li $v1,1
syscall
lw $fp ,0($sp)
lw $ra,4($sp)
addi $sp,$sp,8
li $v1, 10
syscall
mymul:
addi $sp ,$sp ,-4
sw $s0,0($sp)
add $s0 , $a1 ,$0
add $v1 ,$0, $0
beq $s0 , $0, multEol
add $v1,$v1,$a0
addi $s0,$s0,-1
j multloop
multEol:
lw $s0,0($sp)
jr $ra
黑屏出现很多错误,甚至字符串也没有显示