This repository was archived by the owner on Oct 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamforth.begin
More file actions
86 lines (72 loc) · 1.21 KB
/
samforth.begin
File metadata and controls
86 lines (72 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
SamForth Z80
(c) 2009 Victor Marzo <samsaga2@gmail.com>
Based on CamelForth for the Zilog Z80
(c) 1994 Bradford J. Rodriguez
Permission is granted to freely copy, modify,
and distribute this program for personal or
educational use. Commercial inquiries should
be directed to the author at 221 King St. E.,
#32, Hamilton, Ontario L8N 1B5 Canada
Direct-Threaded
BC=TOS
HL=W
DE=IP
SP=PSP
IX=RSP
*/
RAMBASE equ 0e000h
STACKSIZE equ 64*2
PSP equ RAMBASE+STACKSIZE
RSP equ PSP+STACKSIZE
FREERAM equ RSP+1
;; *** ROM HEADER ***
org 04000h
db 041h,042h
dw INIT
ds 12
;; *** FORTH KERNEL ***
macro NEXT
ex de,hl
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ex de,hl
jp (hl)
endm
macro NEXTHL
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ex de,hl
jp (hl)
endm
DOCOLON:
dec ix ; push IP into RSP
ld (ix+0),d
dec ix
ld (ix+0),e
pop hl
NEXTHL
LIT:
push bc ; push TOS into PSP
ld a,(de) ; fetch cell at IP to TOS
ld c,a
inc de
ld a,(de)
ld b,a
inc de
NEXT
EXIT: ld e,(ix+0) ; pop IP from RSP
inc ix
ld d,(ix+0)
inc ix
NEXT
;; *** INIT ***
INIT:
ld sp,PSP ; setup param stack
ld ix,RSP ; setup return stack
ld de,MAIN+3 ; setup IP pointer to CFA MAIN
NEXT