0

Excuse me I'm using a MIPS simulator.

Occurs that when I'm trying to open the text file that contains my code in the simulator appears me this message:

 spim: (parser) syntax error on line 35 of file /home/v-wrampht3r/Desktop/MIPS.s
  mult $s4, $s0, $s1
            ^

And also,when I'm trying to execute it,appears me this other message,which I understand that says which the emulator does not interpret which has an instruction declared in the line where the error has produced:

   Attempt to execute non-instruction at 0x00400050

I leave you it:

      .data
op1:           .word 25

op2:           .word 7

suma:          .word 0
resta:         .word 0
multbajo:      .word 0 
multalto:      .word 0
divis:         .word 0
resto:         .word 0

        .text

main:

     lw   $s0, op1
     lw   $s1, op2
     add  $s2, $s0, $s1  
     sw   $s2, suma
     sub  $s3, $s0, $s1
     sw   $s3, resta
     mult $s4, $s0, $s1
     mfhi $s4, multalto
     mult $s5, $s0, $s1 
     mflo $s5, multbajo 
     div  $s6, $s0, $s1 
     sw   $s6, divis
     div  $s7, $s0, $s1 
     mfhi $s7, resto

The tags suma, resta, multbajo, etc are one below the other, what happens is that,for some reason,in the text are interspersed one with each other.

Michael
  • 57,169
  • 9
  • 80
  • 125
  • Where did you get the idea that `mult` takes 3 operands? – Michael Mar 10 '16 at 19:00
  • 1
    @Michael two of them for do the operation, and the anoher for stock the result – V_WraMphT3R Mar 10 '16 at 19:40
  • @V_WraMphT3R : as Michael suggests, I don't believe the `mult` instruction has a 3 operand variant. Maybe you were thinking of the `mul` instruction? – Michael Petch Mar 10 '16 at 19:55
  • 1
    @ Michael Petch so I should have to delete the $s4 in the mult operation and let the **mfhi $s4, multalto** such the stock operation? – V_WraMphT3R Mar 10 '16 at 20:05
  • 1
    `mfhi` only takes a single operand. So what you really should do is download _MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set_ so that you can look up the correct form of every instruction. – Michael Mar 10 '16 at 20:18
  • 1
    @Michael I already have a manual that indicates what each instruction and what it means – V_WraMphT3R Mar 10 '16 at 20:23
  • 1
    Alright. In that case I don't understand the question. The first thing you should have done when you got that syntax error is to look up the instruction in the instruction set reference and verify that you're using it correctly. – Michael Mar 10 '16 at 20:27
  • 1
    @Michael yes, but then I have a problem because I need to extract the highest value of the result of the multiplication and stock it in the variable suma tag , any advice? – V_WraMphT3R Mar 10 '16 at 20:32
  • 1
    `mfhi` followed by `sw`. Also note that you need to use system call 10 to terminate your program. – Michael Mar 10 '16 at 20:52
  • 1
    @Michael That is, they would have to put **"mfhi sw $s4, suma"** – V_WraMphT3R Mar 11 '16 at 14:39
  • Huh? No. Like I said earlier, look up the instructions in the instruction set reference to see what the valid combination of operands are. There's nothing in there that matches what you just wrote. – Michael Mar 11 '16 at 14:46
  • 1
    @Michael By the way, do you know where to find the address of each byte of a character string with the **.asciiz** tag ? – V_WraMphT3R Mar 11 '16 at 15:36
  • 1
    @Mchael In this case I want to find the adress of each byte of the string **.asciiz "\nMIPS Assembly Language example.\n"** – V_WraMphT3R Mar 11 '16 at 15:39
  • 1
    @Michael so in conclusion I've to put **mhi $s4** **sw $s4, suma** – V_WraMphT3R Mar 22 '16 at 16:00

0 Answers0