0
3 개의 int를 입력으로 받아서 출력을 반환하는 MIPS 계산기를 구현하려고합니다. 현재, 코드는 "int1, int2 및 int3의 합이 1입니다."라고 출력하고 이유를 이해하지 못합니다. 아마도 추가 서브 루틴을 제대로 작성하지 않았을까요?MIPS 계산기가 제대로 출력되지 않는다
.data
welc: .asciiz "Enter an integer:\n"
sum: .asciiz "The sum of "
prod: .asciiz "The product of "
divi: .asciiz "The quotient of "
subt: .asciiz "The difference of "
also: .asciiz " and "
comma: .asciiz ", "
rem: .asciiz "remainder:"
is: .asciiz " is "
int1: .word 1 #space to hold first int
int2: .word 1 #space to hold second int
int3: .word 1 #space to hold third int
input: .space 1 #space to hold raw input
out: .word 1 #space to hold output
remain: .word 1 #space to hold remainder
.text
.globl main
main : li $v0, 4 #syscall 4, print string
la $a0, welc #give argument: string "Enter an integer:"
syscall
li $v0, 5 #tell syscall we want to read int 1
syscall
la $s1, int1 #load int1 into $s1
sw $v0, 0($s1) #copy int from $v0 to int 1
li $v0, 4 #syscall 4, print string
la $a0, welc #give argument: string "Enter an integer:"
syscall
li $v0, 5 #tell syscall we want to read int 2
syscall
la $s2, int2 #load int2 into $s2
sw $v0, 0($s2) #copy int from $v0 to int 2
li $v0, 4 #syscall 4, print string
la $a0, welc #give argument: string "Enter an integer:"
syscall
li $v0, 5 #tell syscall we want to read int 3
syscall
la $s3, int3 #load int3 into $s3
sw $v0, 0($s3) #copy int from $v0 to int 3
la $s0, out #load output to $s0
j plus #jump to calc
plus: add $s0, $s1, $s2 #add int1 and int2 and put in out
add $s0, $s0, $s3 #add out and int3
li $v0, 4 #tell syscall to print string
la,$a0, sum #print sum string
syscall
li $v0, 1 #tell syscall to print int
la $s1, int1 #tell syscall to print int1
lw $a0, 0($s1) #load int 1 into $a0 and print
syscall
li $v0, 4 #tell syscall to print string
la,$a0, comma #tell syscall to print comma
syscall
li $v0, 1 #tell syscall to print int
la $s2, int2 #tell syscall to print int2
lw $a0, 0($s2) #load int 2 into $a0 and print
syscall
li $v0, 4 #tell syscall to print string
la,$a0, comma #tell syscall to print comma
syscall
li $v0, 4 #tell syscall to print string
la,$a0, also #tell syscall to print comma
syscall
li $v0, 1 #tell syscall to print int
la $s3, int3 #tell syscall to print int3
lw $a0, 0($s3) #load int 3 into $a0 and print
syscall
li $v0, 4 #tell syscall to print string
la,$a0, is #tell syscall to print is
syscall
li $v0, 1 #tell syscall to print int
la $s0, out #tell syscall to print output
lw $a0, 0($s0)
syscall
li $v0, 10 #exit code
syscall