1 ;;; This file define/describes the "machine"
4 ;;; https://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture
6 ;;; General Purpose Registers ( * marks those used in syscalls )
7 ;;; *rax = ( -, eax = ( -, ax = ( ah, al) )) "accumulator"
8 ;;; rbx = ( -, ebx = ( -, bx = ( bh, bl) )) "base"
9 ;;; *rcx = ( -, ecx = ( -, cx = ( ch, cl) )) "counter"
10 ;;; *rdx = ( -, edx = ( -, dx = ( dh, dl) )) "data"
11 ;;; rsp = ( -, esp = ( -, sp = ( -, spl) )) "stack pointer"
12 ;;; rbp = ( -, ebp = ( -, bp = ( -, bpl) )) "stack base pointer"
13 ;;; *rsi = ( -, esi = ( -, si = ( -, sil) )) "source"
14 ;;; *rdi = ( -, edi = ( -, di = ( -, dil) )) "destination"
23 ;;; clobbers rdi rsi rdx rcx r8 r9 r11
27 ;;; SS "Stack Segment"
30 ;;; ES "Extra Segment"
31 ;;; FS "more Extra Segment"
32 ;;; GS "more more Extra Segment"
35 ;;; 0,0,0,0,0,0,0,0,0,0,ID,VIP,VIF,AC,VM,RF,
36 ;;; 0,NT,[IOPL,IOPL],OF,DF,IF,TF,SF,ZF,0,AF,0,PF,1,CF
38 ;;; Instruction pointer
41 ;;; Syscall allocations
42 ;;; clobbers rdi rsi rdx rcx r8 r9 r11
48 ;;; rsp = data stack pointer
49 ;;; rbp = frame pointer
51 ;;; rsi = instruction pointer
53 ;;; ========================================
54 ;;; The next macro "moves" execution to the next FORTH instruction,
55 ;;; using rsi as instruction pointer.
58 lodsq ; mov rax, qword [rsi]
60 jmp qword [rax] ; goto code of that FORTH word
63 ;;; ========================================
64 ;;; The pushr macro pushes x onto the return stack
65 ;;; The popr macro pops x from the return stack
76 ;;; ========================================
81 ;; Macro WORD starts a FORTH word definition in this code
82 macro WORD label, name, doer, flags {
88 previous_word = label#_word
92 ;; CFA = pointer to "interpreter"
97 ;; Macro WORD_assembler begins an assembler implementation
98 macro WORD_assembler label, name, flags {
99 WORD label, name, label#_code, flags