Hello I have a MIPS program that tries to accomplish the following image.
.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"
However, I get alot of erros when I run the program.
Assemble: assembling F:\Users\Owner\Desktop\Assign 3a - First Assembler Program Assemble: operation completed successfully.
Go: running Assign 3a - First Assembler Program
Error in : invalid program counter value: 0x00000000
Go: execution terminated with errors.
I am new to MIPS and assembly is very different compare to object oriented programming. How can I change my code so it doesn't throw any errors? I couldn't really find a good source or website in order to learn MIPS. Its either the book or people mostly. Let me know if you know a good source that I can go to.
User contributions licensed under CC BY-SA 3.0