1 ; This is a forth interpreter
2 format elf64 executable
5 ;;; ############################################################
7 segment readable writable executable
11 ;; PROGRAM_VERSION is the program version string
12 WORD program_version, 'PROGRAM_VERSION', marker
14 program_version_string:
16 length = $ - program_version_string
18 ;; MAIN is the program entry point
20 WORD_assembler main, "MAIN"
21 mov rsi,program_version_string ; address of string
22 mov edx,length ; length of string (cheating)
28 ;; TERMINATE0 terminates the program with code 0
30 WORD_assembler terminate0, 'TERMINATE0'
35 ;; EXIT ends a forth code defintion, returning to caller
37 WORD_assembler exit, 'EXIT'
41 ;; MARKER is a word that pushes the address after itself, then exits
43 WORD_assembler marker, 'MARKER'
47 ;; MARKER@ is a word that pushes a the value after itself, then exits
49 WORD_assembler marker_get, 'MARKER@'
53 ;; DOFORTH begins a FORTH defintion
54 WORD_assembler doforth, 'DOFORTH'
59 ;; LIT is a word that pushes a the value after itself, then continues
61 WORD_assembler lit, 'LIT'
66 ;; HERE is a variable pointing to the free heap
67 WORD here, 'HERE', marker
68 dq heap_start ; initialise to first "free" data
70 ;; WORDS is the list of words
71 WORD words, 'WORDS', marker
72 dq forth_tfa ; initialise to last forth word
74 ;; FORTH is the last word of the VOCABULARY
75 WORD forth, 'FORTH', marker_get