Menu

#63 Parse error

v1.0_(example)
closed
nobody
None
1
2015-09-22
2015-09-22
Anonymous
No

This simple program caused a parse error on the label "b:" and it shouldn't have. Changing the label b: to bbb: fixes the problem! Here's the program:

Just a test program

# Data declarations
.data

a: .word 30
b: .word 45
c: .space 4

.text          # to signify the start of your code
.globl  main   # The name of your main program
.ent    main   # optional, used to specify entry point if different from program name

main: lw $s1, a # load a into $s1. (Normally don't put such obvious comments in your code!)
lw $s2, bbb # BUG: Can't use the name b!!!
add $s3, $s1, $s2
sw $s3, c

# Done, now terminate program by returning to the "system"
li  $v0, 10
syscall
.end    main

Discussion

  • Anonymous

    Anonymous - 2015-09-22

    The 2nd executable code text line should read, "lw $s2, b"

     
  • James Larus

    James Larus - 2015-09-22

    The problem is that "b" is the opcode for branch. All of the MIPS opcodes are reserved keywords that can't be used for labels.

     
  • James Larus

    James Larus - 2015-09-22
    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB