如何添加mips?

如何添加mips?,mips,mars-simulator,Mips,Mars Simulator,首先,我知道我问了很多问题,但自从上次问起以来,我已经走了很长一段路 我正在使用火星模拟器进行项目学习。 我一直对汇编感兴趣,mips是我的选择 无论如何,我的程序似乎崩溃后,我试图移动我的价值观,并把他们加起来,我不知道为什么。 感谢您的关注,提示将是伟大的。 祝你今天愉快 .data msg0: .asciiz "enter a number: \n" msg1: .asciiz "enter another number: \n" res

首先,我知道我问了很多问题,但自从上次问起以来,我已经走了很长一段路

我正在使用火星模拟器进行项目学习。 我一直对汇编感兴趣,mips是我的选择

无论如何,我的程序似乎崩溃后,我试图移动我的价值观,并把他们加起来,我不知道为什么。 感谢您的关注,提示将是伟大的。 祝你今天愉快

    .data
msg0: .asciiz "enter a number:  \n"
msg1: .asciiz "enter another number:  \n"
result: .asciiz "result is:  \n"

.text
li $v0, 4
la $a0, msg0   #load first message
syscall

li $v0 5
move $t0, $v0  #user input
syscall         #store number


li $v0, 4
la $a0, msg1    #second msg
syscall

li $v0, 5
move $t1, $v0   #second input and store number
syscall

li $v0, 4
la $a0, result  #rsult message
syscall

add $t3,$t1,$t0  #and my problem is here for some reason?
syscall

您需要添加一个作为函数名的标签。在我下面提供的代码中,函数名是main。另外,最后一次系统调用现在也没有任何作用。您需要做的是,在通过li$v0,10进行最后一次系统调用之前,指出您的代码已经完成

    .data
    msg0: .asciiz "enter a number:  \n"
    msg1: .asciiz "enter another number:  \n"
    result: .asciiz "result is:  \n"

    .text
    .globl main

    main:
    li $v0, 4
    la $a0, msg0   #load first message
    syscall

    li $v0 5
    syscall         
    move $t0, $v0  #first input and store number


    li $v0, 4
    la $a0, msg1    #second msg
    syscall

    li $v0, 5
    syscall
    move $t1, $v0   #second input and store number

    li $v0, 4
    la $a0, result  #result message
    syscall

    add $t3,$t1,$t0  

    move $a0, $t3    
    li $v0, 1        
    syscall     #print answer

    li $v0,10
    syscall

另请参见,最后一个
syscall
没有意义。添加两个寄存器不是系统调用。