\ systraps 05.1.26 JCF
\ Reads systrap names from the
\ internal Quartus Forth resource.

module systraps

: typea ( addr. u -- )
    0 DO
        2DUP c@a EMIT 1 M+
    LOOP 2DROP
;

: qlt.entry ( addr. code -- flag )
    >R
    2DUP 2DUP c@a 1+ ALIGNED M+
    @a R> = IF
        2DUP c@a >R 1 M+ R>
        typea TRUE
    ELSE
        2DROP FALSE
    THEN
;

: .qlt ( base. code -- )
    >R 2DUP
    BEGIN
        2DUP @a DUP WHILE
( pt of )    >R 2OVER R> M+
        R@ qlt.entry 0= WHILE
    2 M+ REPEAT DUP THEN
    DROP 2DROP 2DROP R> DROP
;

public:

: .systrap ( code -- )
    >R
    1 [id] syst DmGetResource
    2DUP MemHandleLock R> .qlt
    2DUP
    MemHandleUnlock THROW
    DmReleaseResource THROW
;

end-module
