Implement string constants, buffers, macro barriers

macro barriers are a hack to say "this form does its own macroexpansion
internally" so that we can have state-smart macros that expand to
different values depending on if they are being used in code or in a
function definition. This seems like a real bad design choice but I
can't think of a better one right now!

(not quite true: the better design choice is to allow forms to return
opgens, and then define a :bytes form that returns the address of the
generated thing. :bytes could be understood by :buffer directly.
But that's... complicated.)
This commit is contained in:
Jeremy Penner 2021-09-26 23:07:36 -04:00
parent 6a92211024
commit 2f59db6766
3 changed files with 15 additions and 3 deletions

Binary file not shown.

View file

@ -17,11 +17,11 @@
5 0x0100 ; desk manager 5 0x0100 ; desk manager
9 0x0100) ; ADB 9 0x0100) ; ADB
(asm pascalhex (db 5) hexbuf (bytes " ")) (buffer hexbuf (cstr " "))
(fn printnum (num) (fn printnum (num)
(long! (ref hexbuf) (HexIt num)) (long! (ref hexbuf) (HexIt num))
(WriteString (far-ref pascalhex))) (WriteCString (far-ref hexbuf)))
(asm event-buffer) (asm event-buffer)
(global word event-what) (global word event-what)

View file

@ -22,15 +22,24 @@
(sec) (xce))) ; re-enter emulation mode (sec) (xce))) ; re-enter emulation mode
(require ssc.stdlib) (require ssc.stdlib)
(require ssc.iigs.toolbox)
(require ssc.iigs.uthernet2) (require ssc.iigs.uthernet2)
(macro out [#(! (WriteLine (far-ref (pstr [$2]))))])
(buffer hexbuf (cstr " "))
(fn printnum (num)
(long! (ref hexbuf) (HexIt num))
(WriteCString (far-ref hexbuf)))
(global word u2-debug-server-connected 0) (global word u2-debug-server-connected 0)
(fn u2-init-debug-server () (fn u2-init-debug-server ()
(out "Starting server")
(u2-reset) (u2-reset)
(u2-udp-server-start 6502) (u2-udp-server-start 6502)
(set! u2-debug-server-connected 0)) (set! u2-debug-server-connected 0))
(asm u2-debug-buffer (bytes [(string.rep "\x00" 1500)])) (buffer u2-debug-buffer 1500)
(predef-fn u2-debug-server-poll () void far) (predef-fn u2-debug-server-poll () void far)
@ -83,6 +92,7 @@
(when (> size 0) (when (> size 0)
(let (msgid (u2-read) (let (msgid (u2-read)
cmd (u2-read)) cmd (u2-read))
(printnum msgid) (out "Got message!")
(u2-read-buf (ref u2-debug-buffer) (- size 2)) (u2-read-buf (ref u2-debug-buffer) (- size 2))
(u2-rx-complete) (u2-rx-complete)
(when (not u2-debug-server-connected) (when (not u2-debug-server-connected)
@ -91,6 +101,8 @@
(u2-debug-server-cmd msgid cmd))))) (u2-debug-server-cmd msgid cmd)))))
(fn debug-server-loop () (fn debug-server-loop ()
(TextStartUp)
(IMStartUp)
(u2-init-debug-server) (u2-init-debug-server)
(while true (u2-debug-server-poll))) (while true (u2-debug-server-poll)))
) )