0

I'm having trouble with my assembly code:

# Program testing 
        .text
        .globl  main

main:   ori $4,$0,1
        addiu $4,$4,2
        addiu $8,$10,4
        addiu $2,$1,1
        addiu $3,$1,1
        addiu $5,$1,1
        j main+8       #ERROR HERE
        sll $0,$0,0

# End of file

I want to add to my jump. My professor says this will work but I keep getting a parser error

My MIPS setting in PCSPIM are:
checked on bare machine, delayed branches, and delayed load.

Does anyone know what is wrong? Is there a word alignment issue?

CubeJockey
  • 2,209
  • 8
  • 24
  • 31
mazie
  • 23
  • 1
  • 6
  • Perhaps SPIM just doesn't support that. You could try `la $t0, main+8` / `jr $t0`, which SPIM seems to accept. – Michael Apr 16 '15 at 12:55

1 Answers1

1

There are no word alignment issues here. Your problem is that the assembler you are using is not interpreting label+displacement as a target address.

As every instruction occupies 4 bytes, you are actually trying to jump two instructions ahead of the main label. Thus, just add a new label where you are really targeting the jump.

i.e.:

# Program testing 
        .text
        .globl  main

main:   ori $4,$0,1
        addiu $4,$4,2
jump_target:
        addiu $8,$10,4
        addiu $2,$1,1
        addiu $3,$1,1
        addiu $5,$1,1
        j jump_target       # main+8
        sll $0,$0,0

# End of file
gusbro
  • 22,357
  • 35
  • 46