[PicForth] Code generation bug involving exit followed by if
Alex Holden
alex at linuxhacker.org
Fri Dec 17 00:42:45 CET 2004
I was trying to track down where my program was going insane (haven't
got to the bottom of that yet), and in order to figure out if it was
somewhere in a particular word I inserted an 'exit' at the beginning of
it, thereby turning the rest of the word into dead-code which should
never execute. Surprisingly the exit seemed to be ignored and the rest
of the word executed anyway. I've distilled it down to this example:
: sometest 1 ;
: dosomething ;
: unreachable ;
main : test exit sometest if dosomething then unreachable ;
Everything after the 'exit' should not execute, and 'unreachable' is,
well, unreachable, right? Here's the generated assembly:
0x0000 018A clrf 0x0A
0x0001 280A goto 0x00A ; (init-picforth)
; name: sometest
; max return-stack depth: 0
0x0004 3001 movlw 0x01
0x0005 0384 decf 0x04,f
0x0006 0080 movwf 0x00
0x0007 0008 return
; name: dosomething
; max return-stack depth: 0
0x0008 0008 return
; name: unreachable
; max return-stack depth: 0
0x0009 0008 return
; name: (init-picforth)
; max return-stack depth: 0
0x000A 3032 movlw 0x32
0x000B 0084 movwf 0x04
; name: test
; max return-stack depth: 0
0x000C 280D goto 0x00D ; test + 0x001
0x000D 2809 goto 0x009 ; unreachable
I wonder if this might somehow be related to the 'dead code getting
executed' bug I reported on the 29th of November? I don't think that one
has been fixed yet.
--
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer
More information about the PicForth
mailing list