MIPS计划,我做错了什么?

时间:2015-02-07 17:52:54

标签: assembly mips mars-simulator

您好我有一个MIPS程序试图完成以下图像。

enter image description here

.text #begin code text segment
.globl main #program entry point
main:
        la $a0, prompt1     #load prompt1
    li $v0, 4       #syscall code for print string
    syscall         #print string  print prompt.

    li $v0, 5           #syscall code to read integer
    syscall         #read integer into $v0
    move $t1, $v0

    la $a0, prompt2         #load prompt2
    li $v0, 4       #syscall code for print string
    syscall         #print string  print prompt.

    li $v0, 5           #syscall code to read integer
    syscall         #read integer into $v0
    move $t2, $v0

    la $a0, prompt3         #load prompt3
    li $v0, 4       #syscall code for print string
    syscall         #print string  print prompt.

    li $v0, 5           #syscall code to read integer
    syscall         #read integer into $v0
    move $t3, $v0


    add $t0, $t1, $t2   #t3 = t1 + t2
    add     $t0, $t3, $t0   #t3 = t3+ t0

    la  $a0, ans1       #load address for ans1 string to a0
    li  $v0, 4          #load print string code into v0
    syscall                 #print the ans1 string


    move    $a0, $t0            #(t0) -> a0
    li  $v0, 1              # load syscall code to print integer
    syscall             # display integer result of conversion
     la $a0, end1           #load address of end1 CR/LF code
    li  $v0,4               #load syscall code for string output
    syscall             #output CR/LF 

    j     findMin3

        la  $a0, loop       #load address for loop string to a0
    li  $v0, 4          #load print string code into v0
    syscall                 #print the ans1 string


    li $v0, 5           #syscall code to read integer
    syscall         #read integer into $v0
    move $t5, $v0

        la  $a0, end1           #load address of end1 CR/LF code
    li  $v0,4               #load syscall code for string output
    syscall             #output CR/LF 

        beq    $t5,0 ,main             #checks if the value is equal to 0
        li     $v0,10                  #ends the code 
        syscall 

           findMin3:
        move $t0,$t1              # min = x
             bge  $t2,$t0, IF_two     #branch  if  y < min
             move  $t0, $t2          #min = y
 IF_two:     bge  $t2, $t0, END   # branch if z<min
            move  $t0, $t3        #min = z
 END:      move  $v0, $t0    #retrieve val
            jr  $ra           #return

.data # begin the data segment

end1:.asciiz "\n"
prompt1:.asciiz "Enter the  first integer: "
end1:.asciiz "\n"
prompt2:.asciiz "Enter the second integer: "
end1:.asciiz "\n"
prompt3:.asciiz "Enter the third integer: "
end1:.asciiz "\n"
ans1:.asciiz "The sum of the three integers is is: "
end1:.asciiz "\n"
end1:.asciiz "\n"
loop:.asciiz "0 to start again "
end1:.asciiz "\n"

然而,当我运行程序时,我得到了很多错误。

组装:组装F:\ Users \ Owner \ Desktop \ Assign 3a - First Assembler Program -EnesOguz.asm

组装:操作成功完成。

Go: running Assign 3a - First Assembler Program-EnesOguz.asm

Error in : invalid program counter value: 0x00000000

Go: execution terminated with errors.

我是MIPS的新手,与面向对象编程相比,汇编非常不同。如何更改我的代码,以免出错?我无法找到一个好的来源或网站来学习MIPS。无论是书还是人。如果您知道我可以去的好消息来源,请告诉我。

0 个答案:

没有答案
相关问题