메인 프로그램에 문제가 있습니다. 나는 비트가 함수 dumpb와 dumbw와 dumpreg (나는 생각한다)에 전달되도록 허용 할 필요가있다. 현재 출력으로 제로를 얻고 있지만 그것이 내가 얻고있는 것으로 생각하지 않습니다. 누군가 나를 제발 도와 주거나 적어도 내 실수가있는 곳에서 올바른 방향으로 나를 가리킬 수 있습니까?Assembly Mips Program 메인 콜
.data
n_elem: .word 10
.text
.globl main
main:
jal dumpreg
jal prword
jal prchar
#insert element to dump
jal dumpb
#insert element to dump
jal dumpw
addi $v0, $0, 10 #exit program
syscall
dumpw:
addi $sp, $sp, -16 #allocates memory
sw $a0, 12($sp)
sw $v0, 8($sp)
sw $t0, 4($sp)
sw $t1, 0($sp)
lw $t0, 20($sp) # load n_elem
lw $t1, 16($sp) # load address
looptop:
beq $t0, $0, bailout
lw $a0, 0($t1) # a0 = address[i]
addi $v0, $0, 1
syscall
addi $t0, $t0, -1
addi $t1, $t1, 4
j looptop
bailout:
lw $t1, 0($sp)
lw $t0, 4($sp)
lw $v0, 8($sp)
lw $a0, 12($sp)
addi $sp, $sp, 16
jr $ra
dumpb:
addi $sp, $sp, -16
sw $a0, 12($sp)
sw $v0, 8($sp)
sw $t0, 4($sp)
sw $t1, 0($sp)
lw $t0, 20($sp) # load n_elem
lw $t1, 16($sp) # load address
looptopb:
beq $t0, $0, bailoutb
lb $a0, 0($t1) # a0 = address[i]
addi $v0, $0, 11
syscall
addi $t0, $t0, -1
addi $t1, $t1, 1
j looptopb
bailoutb:
lw $t1, 0($sp)
lw $t0, 4($sp)
lw $v0, 8($sp)
lw $a0, 12($sp)
addi $sp, $sp, 16
jr $ra
prspace:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $ra, 4($sp)
addi $a0, $0, ' '
addi $sp, $sp, -4 #push it
sw $a0, 0($sp)
jal prchar
addi $sp, $sp, 4
lw $a0, 0($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
prcomma:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $ra, 4($sp)
addi $a0, $0, ',' #
addi $sp, $sp, -4 #push it
sw $a0, 0($sp)
jal prchar
addi $sp, $sp, 4
lw $a0, 0($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
prnl:
addi $sp, $sp, -8
sw $a0, 0($sp)
sw $ra, 4($sp)
addi $a0, $0, 0x0A # 0xA new line char
addi $sp, $sp, -4 #push it
sw $a0, 0($sp)
jal prchar
addi $sp, $sp, 4
lw $a0, 0($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
prchar:
addi $sp, $sp, -8
sw $a0, 4($sp)
sw $v0, 0($sp)
lw $a0, 8($sp)
addi $v0, $0, 11
syscall
lw $v0, 0($sp)
lw $a0, 4($sp)
addi $sp, $sp, 8
jr $ra
prbyte:
addi $sp, $sp, -8
sw $a0, 4($sp)
sw $v0, 0($sp)
lw $a0, 8($sp)
addi $v0, $0, 1
syscall
lw $v0, 0($sp)
lw $a0, 4($sp)
addi $sp, $sp, 8
jr $ra
dumpreg:
addi $sp, $sp, -4
sw $ra, 0($sp)
jal prnl
addi $sp, $sp, -4
jal prspace
sw $a0, 0($sp)
jal prword
jal prspace
sw $a1, 0($sp)
jal prword
jal prspace
sw $t0, 0($sp)
jal prword
jal prspace
sw $t1, 0($sp)
jal prword
jal prspace
sw $t2, 0($sp)
jal prword
jal prspace
sw $t3, 0($sp)
jal prword
jal prspace
sw $t4, 0($sp)
jal prword
jal prspace
sw $s0, 0($sp)
jal prword
jal prspace
sw $s1, 0($sp)
jal prword
addi $sp, $sp, 4
jal prnl
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
prword:
addi $sp, $sp, -8
sw $a0, 4($sp)
sw $v0, 0($sp)
lw $a0, 8($sp)
addi $v0, $0, 1
syscall
lw $a0, 4($sp)
lw $v0, 0($sp)
addi $sp, $sp, 8
jr $ra
아무도이 문제를 해결할 수 있습니다. 당신은 그것이 작동하지 않는다고 확신하지 못합니다. –