"Michael Kalus" <mi-ka...@t-online.de>
writes:

> Hi Matthias.
>
> ...
>> There is currently no
>> way to switch between forth and machine code (that would
>> be ;CODE btw)
>
>
> You may go from low to high level and back:
>
> code <name>
> (some code)
> ; -- jump to high level:
>     ldi  XL,low(pfa_forthISR)
>     ldi  XH,high(pfa_forthISR)
>     jmp  DO_NEXT
> pfa_forthISR:
>     .dw  XT_MAINWORD
> ; -- back to low level:
>     .dw  PC+1  ; next IP
>     .dw  PC+1  ; next cfa
> (more code )
> end-code
>
> But be shure to save all registers you use if you do so.
>
> ---
>
> Enochs code is a macro, assembling one single instruction SBI into  
> dictionary and naming it.
> Calling that word will execute the SBI instruction.
>
> Michael

I confirm, the code works. I was not aware we have ;code as in other
implementations. The idea came when examining lib/assembler-test.frt

I suggest that these simple macros would become standard library
offerings.  Without these atomic bit set/clear one needs to wrap code by
-int/+int if register bits are shared by different interrupt
routines. In my current project (at90can128 based) the AVR also has a
recommended general purpose register, GPIOR0 [0x1E (0x3E)], for this
very purpose.

Thank you, Enoch.

----------------------------------------------------------------------

: _bitio
    dup $1F U> if &-9 throw then
    over $7 U> if &-9 throw then
;

: port:hi!  ( portadr bitno -- )            \ SBI
    swap $20 - _bitio
    3 lshift or $9A00 or
    code , end-code
;

: port:lo!  ( portadr bitno -- )            \ CBI
    swap $20 - _bitio
    3 lshift or $9800 or
    code , end-code
;

----------------------------------------------------------------------


>
>
>
>
> Am 14.02.2013 um 20:14 schrieb Matthias Trute:
>
>> hi Enoch,
>>
>>
>>> I'd like to see this forum also offering code snippets, so here's my
>>> first humble attempt of harnessing the atomic bit manipulation
>>> instructions.
>>>
>>> : port:hi ( portadr bitno -- )          \ SBI
>>>     swap $20 - 3 lshift or $9A00 or code , end-code
>>
>> Did you actually test this code? CODE is a parsing word
>> that starts a new dictionary entry. There is currently no
>> way to switch between forth and machine code (that would
>> be ;CODE btw)
>>
>> Puzzled
>> Matthias
>>
>>
>> ---------------------------------------------------------------------- 
>> --------
>> Free Next-Gen Firewall Hardware Offer
>> Buy your Sophos next-gen firewall before the end March 2013
>> and get the hardware for free! Learn more.
>> http://p.sf.net/sfu/sophos-d2d-feb
>> _______________________________________________
>> Amforth-devel mailing list for http://amforth.sf.net/
>> Amforth-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/amforth-devel
>
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013 
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb


------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to