Tonight, I've spent some time playing with interrupts, multi-tasking and 32 bit code. It's been a thrill to get something working.
I got the following Hello World code to work, running in a native mode task called from an emulation mode task. This is the first 32 bit code that has been tried.
Internally the core manipulates 32 bit values for it's value processing (essentially the ALU is 32 bits). It then truncates the 32 bit values down to 8 and 16 bits for emulation modes. So it's not surprising that the 32 bit code works once the bugs have been ironed out testing with 16 bit code.
Code:
; This little task sample runs in native 32 bit mode and displays
; "Hello World!" on the screen.
CPU FT832
MEM 8
NDX 32
Task2:
LDX #84*2*3 ; places text beginning on the third line of the display
.0003:
LDY #0
.0002:
LDA msgHelloWorld,Y ; get a message char
BEQ .0001 ; terminator char detected ?
JSR AsciiToScreen8 ; convert ascii to screen character using eight bit acc
STA VIDBUF,X ; store in text video buffer
INX ; increment the text index
INX
INY ; index to next message character
BRA .0002
.0001:
RTT ; return to the calling task
BRA .0003 ; for the next iteration, loop back
msgHelloWorld:
.byte CR,LF,"Hello World!",CR,LF,0
You may notice the branch directly after the RTT. This branch is necessary because the next time the task is invoked it will begin executing code at the next instruction after the RTT.
Invoking a task isn't quite the same as calling a subroutine.
Also the number of task context registers has been increased to 512 from 256. Apparently this does not increase the resource requirements in the FPGA. Only half of the RAM was being utilized. My initial thoughts were to provide for only a small number of tasks, since this is more likely to be used for embedded systems.