Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;; Header / dictionary construction macros (not portable)
- ;;
- ;; Header layout:
- ;; [ pfa ] 0x04 Optional PFA pointers (primitives don't have this)
- ;; cfa 0x04 CFA - code pointer
- ;; link 0x02 16-bit offset back to previous word
- ;; count 0x01 8-bit word length count
- ;; name 0x?? name string (count bytes)
- ;; pad 0x?? inserted as required for 32-bit alignment
- ;;
- ;; Note that words with count = 1, 5, 9, ... are
- ;; perfect fits (no padding)
- %macro symbol 2 ; create link, name, pad
- %2_n: dw %2_n-NFA
- %define NFA %2_n
- %strlen count %1
- db count
- db %1
- align 0x04, db 0x00
- %endmacro
- %macro symbol 3 ; create link, name, pad w/ tags
- ; %if %3-COVERT ; o 0x8000 : inline argument cell
- %2_n: dw %2_n-NFA+%3 ; o 0x0002 : covert word
- %define NFA %2_n ; o 0x0001 : immediate word
- %strlen count %1
- db count
- db %1
- align 0x04, db 0x00
- ; %endif
- %endmacro
- %macro code 2 ; machine code primitives
- section .data
- %2: dd %2_p-o
- symbol %1, %2
- section .text
- %2_p:
- %endmacro
- %macro code 3 ; machine code primitives
- section .data
- %2: dd %2_p-o
- symbol %1, %2, %3
- section .text
- %2_p:
- %endmacro
- %macro def 2 ; Standard Forth definitions
- section .data
- dd %2_p-o
- %2: dd docol_c-o
- symbol %1, %2
- section .text
- align 0x04
- %2_p:
- %endmacro
- %macro def 3 ; Tagged Forth definitions
- section .data
- dd %2_p-o
- %2: dd docol_c-o
- symbol %1, %2, %3
- section .text
- align 0x04
- %2_p:
- %endmacro
- %macro var 2 ; System global Variables
- section .data
- dd %2_p-o
- %2: dd dovar_c-o
- symbol %1, %2
- section .text
- align 0x04
- %2_p:
- %endmacro
- %macro var 3 ; System global Variables
- section .data
- dd %2_p-o
- %2: dd dovar_c-o
- symbol %1, %2, %3
- section .text
- align 0x04
- %2_p:
- %endmacro
- %macro const 2
- section .data
- dd %2_p-o
- %2: dd docon_c-o
- symbol %1, %2
- section .text
- align 0x04
- %2_p:
- %endmacro
- %macro run 1-*
- %rep %0
- dd %1-do
- %rotate 1
- %endrep
- %endmacro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement