[PicForth] multitasker.fs yield seems to generate bad code when
multitasker is above 0x1000
Alex Holden
alex at linuxhacker.org
Sun Dec 5 23:09:15 CET 2004
My program went over 0x1000 instructions and immediately started
crashing hard on boot again. It seems to be caused by another
(different) issue with the code which 'yield' in multitasker.fs
generates. In my program it's generating an 'andlw 0xca' instruction
instead of a goto - I couldn't seem to replicate that exactly with a
minimal example but it is generating 'iorlw 0x18' instead. I'm guessing
here but I think maybe it's trying to generate 'goto 0x18' and the
instruction is getting corrupted by an overflow resulting from the
address being greater than 0xfff. Here's the example code:
$1000 org
include multitasker.fs
task : test1 yield ;
main : test multitasker ;
And the generated code. Note the instruction at address 0x1005 (this
becomes a goto if you delete the $1000 org above):
0x0000 3010 movlw 0x10
0x0001 008A movwf 0x0A
0x0002 2807 goto 0x007 ; (init-picforth) (0x1007)
; name: test1
; max return-stack depth: 0
0x1000 3010 movlw 0x10
0x1001 00A5 movwf 0x25
0x1002 0822 movf 0x22,w
0x1003 008A movwf 0x0A
0x1004 3006 movlw 0x06
0x1005 3818 iorlw 0x18
0x1006 0008 return
; name: (init-picforth)
; max return-stack depth: 0
0x1007 303E movlw 0x3E
0x1008 0084 movwf 0x04
0x1009 302E movlw 0x2E
0x100A 00A3 movwf 0x23
0x100B 3000 movlw 0x00
0x100C 00A4 movwf 0x24
0x100D 3010 movlw 0x10
0x100E 00A5 movwf 0x25
; name: test
; max return-stack depth: 0
0x100F 3010 movlw 0x10
0x1010 00A2 movwf 0x22
0x1011 0064 clrwdt
0x1012 0823 movf 0x23,w
0x1013 0084 movwf 0x04
0x1014 0825 movf 0x25,w
0x1015 008A movwf 0x0A
0x1016 0824 movf 0x24,w
0x1017 0082 movwf 0x02
0x1018 00A4 movwf 0x24
0x1019 0804 movf 0x04,w
0x101A 00A3 movwf 0x23
0x101B 2811 goto 0x011 ;
--
------------ 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