Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Missing label issue *found*
#1
I have a program (fourspriter. Yet again!) that has a compilation error "no such label". Except I can see it. Right there! :-)

Am I going crazy?

I copied and pasted the following code into a separate project:

Code:
SUB FASTCALL fspUpdate()
asm
fspUpdateAsm:
         ld     hl, fspDataStartAsm+1     ; Points to sprite 1
         ld     de, fspDataStartAsm+3            
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43     ; Points to sprite 2
         ld     de, fspDataStartAsm+3+43                  
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43     ; Points to sprite 3
         ld     de, fspDataStartAsm+3+43+43                
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43+43     ; Points to sprite 4
         ld     de, fspDataStartAsm+3+43+43+43                    
         ldi
         ldi
         ret
END asm
END SUB

SUB fspCollisionCheck()
END SUB


SUB FASTCALL fspRedraw()
   fspCollisionCheck()
asm
   halt
   call fspEraseAsm
   call fspBufferAndDrawAsm
   call fspUpdateAsm
end asm                                          
END SUB

fspRedraw()

And it compiled perfectly. Which is bad, because this is FULL of references that don't exist. However, when I try the main code block, it reports:

FourSpriter3.bas:906: Error: Undefined label 'fspUpdateAsm'

Now, quite apart from the fact that line 906 reads " ;LD BC,2120 "- which means I have to hunt down the line it really means, that label is only used in two places. Both of those places are shown in the code above. One call and one arrival point.

I have NO idea why it's doing this. It's weird that it doesn't like the label in the main program, and yet is fine with all those other undefined labels in the part above. Any idea what's going on here?
Reply
#2
Oh..

-O3 was in the build. I'm guessing the optimizer...er optimized it out of existence.

*sigh* Sometimes it's tricky, this programming thing. Especially with half-built code.
Reply
#3
britlion Wrote:Oh..

-O3 was in the build. I'm guessing the optimizer...er optimized it out of existence.

*sigh* Sometimes it's tricky, this programming thing. Especially with half-built code.
Mixing ASM with a high level language is always tricky on any compiler (even GCC, Borland Pascal, etc...). And should be used only in special cases (high performance routines, graphics or sound). Other than that you should avoid it as much as possible: the compiler DOES NOT understand ASM but basic. When it enters and ASM block it just skips it and pass it to the assembler on a 2nd stage along with the ASM code it generates. It will try even to make some optimizations on your code, but will mostly not since it won't know your "intentions" (semantics).

Regarding to your error, you are defining a label *within* an ASM block and calling it from outside (BASIC Environment). Move the fspUpdateAsm: label out of the asm block and put it just above the ASM... opening. This should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)