|
From: Kalus M. <mic...@on...> - 2010-09-09 18:49:55
|
Am 09.09.2010 um 20:10 schrieb Matthias Trute:
...
> There is no way to use forth words from within the
> assembler code. For that you need to initialize
> a forth vm and call it. The only "guide" for that
> is the startup code itself (amforth.asm).
and goes like this:
<snip>
sei ; global interupt enable.
push XL
push XH
lds XL,0x5F ; status register
push XL
.. maybe you have to include even more registers
push R22 ; tosl = r22
push R23 ; tosh = r23
push R24 ; wl
push R25 ; wh
push YL
push YH
push ZL
push ZH
...
<your code>
...
; switch to high level forth: :
sei
ldi XL,low(pfa_forthISR)
ldi XH,high(pfa_forthISR)
jmp DO_NEXT
; -- pointer to NEXT word:
pfa_forthISR:
.dw XT_MAINWORD
; -- come back to code:
.dw PC+1 ; next IP
.dw PC+1 ; next cfa
...
<more of your code>
...
pop ZH
pop ZL
pop YH
pop YL
pop R25
pop R24
pop R23
pop R22
.. maybe you have to include even more registers
pop XL
sts 0x5F,XL
pop XH
pop XL
jmp DO_NEXT (or RTI if you are in an ISR)
</snip>
see examples in paper VD1/2010 http://www.forth-ev.de/filemgmt/
viewcat.php?cid=53
worked with amforth3.6
still good with 4.1?
Michael
|