PCSpim Addition Error

489 Views Asked by At
#    PROGRAM TO ADD TWO NUMBERS 
        .text           #directive identifying the start of instructions 
        .globl  __start

__start:

    #print
        la      $a0, prompt     #prompt goes in 
        li      $v0, 4         
        syscall

    #read in integer 
        li      $v0, 5          # service code 
        syscall 
        sw      $v0, Num1       # store what was entered 
    #read another 
        li      $v0, 5          # service code 
        syscall 
        sw      $v0, Num2       # store what was entered

    #do the addition
        lw      $t0, Num1 
        add     $a0, $t0, $v0

    #print the sum
        li      $v0, 1          # print integer service call 
        syscall

    #print a final string line 
        la      $a0, final 
        li      $v0, 4 
        syscall

        li      $v0, 10         # exit program service 
        syscall

    #Data segment 

        .data 
Num1:   .word   0 
Num2:   .word   0 
prompt: .ascii  "Please type 2 integers, end each with the " 
        .asciiz "Enter key:\n" 
final:  .asciiz " is the sum.\n"

I am using PCSpim 9.1.9. I tried to reinstall PcSpim but it is still not working. I am getting error " spim: (parser) syntax error on line 8 of file. la $a0, prompt #prompt goes in.

Please Help

0

There are 0 best solutions below