From 9e53bf4532f9e2919a9c17aa7bf4daaea31c6f77 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Wed, 20 Nov 2019 18:22:11 -0800 Subject: [PATCH] getting ready for the Neon816 --- platforms/Neon816/Neon816.l | 16 +++++ platforms/Neon816/Neon816.s | 40 ++++++++++++ platforms/Neon816/README.md | 14 ++++ platforms/Neon816/build.sh | 7 ++ platforms/Neon816/platform-config.inc | 2 + platforms/Neon816/platform-lib.s | 94 +++++++++++++++++++++++++++ platforms/Neon816/platform-words.s | 2 + 7 files changed, 175 insertions(+) create mode 100644 platforms/Neon816/Neon816.l create mode 100644 platforms/Neon816/Neon816.s create mode 100644 platforms/Neon816/README.md create mode 100755 platforms/Neon816/build.sh create mode 100644 platforms/Neon816/platform-config.inc create mode 100644 platforms/Neon816/platform-lib.s create mode 100644 platforms/Neon816/platform-words.s diff --git a/platforms/Neon816/Neon816.l b/platforms/Neon816/Neon816.l new file mode 100644 index 0000000..d99a250 --- /dev/null +++ b/platforms/Neon816/Neon816.l @@ -0,0 +1,16 @@ +FEATURES { + STARTADDRESS: default = $8000; +} + +MEMORY { + ROM: start = $8000, size = $7800, file = %O; + ZP: start = $0000, size = $100; +} + +SEGMENTS { + FStartup: load=ROM,type=ro; + FSystem: load=ROM, type=ro; + FCode: load=ROM, type=ro, optional=yes; + ZEROPAGE: load=ZP, type=bss; +} + diff --git a/platforms/Neon816/Neon816.s b/platforms/Neon816/Neon816.s new file mode 100644 index 0000000..7b50726 --- /dev/null +++ b/platforms/Neon816/Neon816.s @@ -0,0 +1,40 @@ +.p816 +.a16 +.i16 +.include "macros.inc" +.import _Forth_initialize +.import _Forth_ui +.import _system_interface + +.pushseg +.segment "FStartup" +.proc startup + clc + xce + rep #SHORT_A|SHORT_I + lda #$0300 ; direct page for Forth + tcd + lda #.hiword($020000) ; top of dictionary memory + pha + lda #.loword($020000) + pha + lda #.hiword($010000) ; bottom of dictionary + pha + lda #.loword($010000) + pha + lda #$0300 ; first usable stack cell (relative to direct page) + pha + lda #$0100 ; last usable stack cell+1 (relative to direct page) + pha + lda #$09FF ; return stack first usable byte + pha + lda #.hiword(_system_interface) + pha + lda #.loword(_system_interface) + pha + jsl _Forth_initialize + jsl _Forth_ui + brk + .byte $00 +.endproc +.popseg diff --git a/platforms/Neon816/README.md b/platforms/Neon816/README.md new file mode 100644 index 0000000..b6c4b6c --- /dev/null +++ b/platforms/Neon816/README.md @@ -0,0 +1,14 @@ +# Nein816 + +This is a port to Lenore Byron's [Neon816](https://hackaday.io/project/164325-neon816) +system. To build it, change to the platform directory and run +build.sh. Right now, this does not produce a working Forth because I don't know +how to interact with the hardware just yet. That being siad, it will +output a binary named "forth" that isn't suitable for anything, just yet. + +Details about how to buld it for RAM/ROM/whatnot will be forthcoming. + +## Port Features + +Hopefully this section will be filled up with stuff that works like Lenore's +Forth. See the [Neon816 Manual](https://cdn.hackaday.io/files/1643257030480800/sysmanual.pdf) diff --git a/platforms/Neon816/build.sh b/platforms/Neon816/build.sh new file mode 100755 index 0000000..d0effbc --- /dev/null +++ b/platforms/Neon816/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e -x +ca65 -I ../../inc Neon816.s -l Neon816.lst +../../build.sh Neon816 +ld65 -C Neon816.l -S 0x8000 Neon816.o ../../forth.o -m forth.map -o forth +ls -l forth + diff --git a/platforms/Neon816/platform-config.inc b/platforms/Neon816/platform-config.inc new file mode 100644 index 0000000..43684c5 --- /dev/null +++ b/platforms/Neon816/platform-config.inc @@ -0,0 +1,2 @@ +; nothing here yet! + diff --git a/platforms/Neon816/platform-lib.s b/platforms/Neon816/platform-lib.s new file mode 100644 index 0000000..3a8ec08 --- /dev/null +++ b/platforms/Neon816/platform-lib.s @@ -0,0 +1,94 @@ +; Platform support library for Neon816 +; + +cpu_clk = 14000000 + +.proc _system_interface + ;wdm 3 + phx + asl + tax + jmp (table,x) +table: .addr _sf_pre_init + .addr _sf_post_init + .addr _sf_emit + .addr _sf_keyq + .addr _sf_key + .addr _sf_fcode + .addr _sf_reset_all +.endproc +.export _system_interface + +.proc _sf_success + lda #$0000 + tay + clc + rtl +.endproc + +.proc _sf_fail + ldy #.loword(-21) + lda #.hiword(-21) + sec + rtl +.endproc + + +.proc _sf_pre_init + plx + jmp _sf_success ; we'll see what we need to do +.endproc + +.proc _sf_post_init + plx + jmp _sf_success +.endproc + +.proc _sf_emit + plx ; get forth SP + jsr _popay ; grab the top item + phx ; and save new SP + ; TODO: interact with the hardware here + plx + jmp _sf_success +.endproc + +.proc _sf_keyq + ldy #$0000 ; anticipate false + ; TODO: interact with the hardware here, set y to FFFF if char available + tya + plx + jsr _pushay + jmp _sf_success +.endproc + +.proc _sf_key + ; TODO: interact with hardware, wait for char, get it into Y + lda #$0000 + plx + jsr _pushay + jmp _sf_success +.endproc + +.proc _sf_fcode +.if include_fcode + ldy #.loword(list) + lda #.hiword(list) +.else + lda #$0000 + tay +.endif + plx + jsr _pushay + jmp _sf_success +.if include_fcode +list: + .dword 0 +.endif +.endproc + +; TODO.... +.proc _sf_reset_all + plx + jmp _sf_fail +.endproc diff --git a/platforms/Neon816/platform-words.s b/platforms/Neon816/platform-words.s new file mode 100644 index 0000000..8c6e659 --- /dev/null +++ b/platforms/Neon816/platform-words.s @@ -0,0 +1,2 @@ +; Platform support dictionary words for Neon816 +