first session programming _within_ the Mu computer
I tried building a function to draw a horizontal line across the screen. Here's what I have in data.txt: ( (globals . ( (horline . (fn () (screen y) (horline_1 screen y 0 (width screen)))) (horline_1 . (fn () (screen y lo hi) (if (>= lo hi) () ((fn () (pixel screen lo y 12) (horline_1 screen y (+ lo 1) hi)))))) )) (sandbox . (horline_1 screen 0 0 20)) ) $ dd if=/dev/zero of=data.img count=20160 $ cat data.txt |dd of=data.img conv=notrunc $ ./translate shell/*.mu && qemu-system-i386 -hda disk.img -hdb data.img Result: I can't call (horline screen 0) over a fake screen of width 40. Some stream overflows somewhere after all the tweaks to various fixed-size buffers scattered throughout the app. Calling horline_1 gets to a 'hi' column of 20, but not to 30.
This commit is contained in:
parent
de993bc0cd
commit
6392f1fde9
|
@ -27,6 +27,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
var nil?/eax: boolean <- nil? in-addr
|
var nil?/eax: boolean <- nil? in-addr
|
||||||
compare nil?, 0/false
|
compare nil?, 0/false
|
||||||
break-if-=
|
break-if-=
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "nil|", 7/fg, 0/bg
|
||||||
# nil is a literal
|
# nil is a literal
|
||||||
trace-text trace, "eval", "nil"
|
trace-text trace, "eval", "nil"
|
||||||
copy-object _in, out
|
copy-object _in, out
|
||||||
|
@ -38,6 +39,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
# numbers are literals
|
# numbers are literals
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "number|", 7/fg, 0/bg
|
||||||
trace-text trace, "eval", "number"
|
trace-text trace, "eval", "number"
|
||||||
copy-object _in, out
|
copy-object _in, out
|
||||||
trace-higher trace
|
trace-higher trace
|
||||||
|
@ -47,7 +49,9 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
{
|
{
|
||||||
break-if-!=
|
break-if-!=
|
||||||
trace-text trace, "eval", "symbol"
|
trace-text trace, "eval", "symbol"
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "syma|", 7/fg, 0/bg
|
||||||
lookup-symbol in-addr, out, env-h, globals, trace, screen-cell, keyboard-cell
|
lookup-symbol in-addr, out, env-h, globals, trace, screen-cell, keyboard-cell
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "symz|", 7/fg, 0/bg
|
||||||
trace-higher trace
|
trace-higher trace
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -90,6 +94,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
break-if-=
|
break-if-=
|
||||||
#
|
#
|
||||||
trace-text trace, "eval", "quote"
|
trace-text trace, "eval", "quote"
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "quote|", 7/fg, 0/bg
|
||||||
copy-object rest-ah, out
|
copy-object rest-ah, out
|
||||||
trace-higher trace
|
trace-higher trace
|
||||||
return
|
return
|
||||||
|
@ -110,6 +115,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
compare set?, 0/false
|
compare set?, 0/false
|
||||||
break-if-=
|
break-if-=
|
||||||
#
|
#
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "set|", 7/fg, 0/bg
|
||||||
trace-text trace, "eval", "set"
|
trace-text trace, "eval", "set"
|
||||||
trace-text trace, "eval", "evaluating second arg"
|
trace-text trace, "eval", "evaluating second arg"
|
||||||
var rest/eax: (addr cell) <- lookup *rest-ah
|
var rest/eax: (addr cell) <- lookup *rest-ah
|
||||||
|
@ -208,13 +214,13 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel
|
||||||
var evaluated-list/eax: (addr cell) <- lookup *evaluated-list-ah
|
var evaluated-list/eax: (addr cell) <- lookup *evaluated-list-ah
|
||||||
var function-ah/ecx: (addr handle cell) <- get evaluated-list, left
|
var function-ah/ecx: (addr handle cell) <- get evaluated-list, left
|
||||||
var args-ah/edx: (addr handle cell) <- get evaluated-list, right
|
var args-ah/edx: (addr handle cell) <- get evaluated-list, right
|
||||||
#? dump-cell args-ah
|
#? set-cursor-position 0/screen, 0, 0
|
||||||
#? abort "aaa"
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "a", 7/fg, 0/bg
|
||||||
apply function-ah, args-ah, out, globals, trace, screen-cell, keyboard-cell
|
apply function-ah, args-ah, out, globals, trace, screen-cell, keyboard-cell
|
||||||
trace-higher trace
|
trace-higher trace
|
||||||
# trace "=> " out {{{
|
# trace "=> " out {{{
|
||||||
{
|
{
|
||||||
var stream-storage: (stream byte 0x40)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/ecx: (addr stream byte) <- address stream-storage
|
var stream/ecx: (addr stream byte) <- address stream-storage
|
||||||
write stream, "=> "
|
write stream, "=> "
|
||||||
print-cell out, stream, 0/no-trace
|
print-cell out, stream, 0/no-trace
|
||||||
|
@ -290,7 +296,9 @@ fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), _b
|
||||||
# evaluate each expression, writing result to `out`
|
# evaluate each expression, writing result to `out`
|
||||||
{
|
{
|
||||||
var curr-ah/eax: (addr handle cell) <- get body, left
|
var curr-ah/eax: (addr handle cell) <- get body, left
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "before call|", 7/fg, 0/bg
|
||||||
evaluate curr-ah, out, *new-env-ah, globals, trace, screen-cell, keyboard-cell
|
evaluate curr-ah, out, *new-env-ah, globals, trace, screen-cell, keyboard-cell
|
||||||
|
#? draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "y", 7/fg, 0/bg
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
body-ah <- get body, right
|
body-ah <- get body, right
|
||||||
|
@ -386,7 +394,7 @@ fn push-bindings _params-ah: (addr handle cell), _args-ah: (addr handle cell), o
|
||||||
fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), screen-cell: (addr handle cell), keyboard-cell: (addr handle cell) {
|
fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), screen-cell: (addr handle cell), keyboard-cell: (addr handle cell) {
|
||||||
# trace sym
|
# trace sym
|
||||||
{
|
{
|
||||||
var stream-storage: (stream byte 0x40)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/ecx: (addr stream byte) <- address stream-storage
|
var stream/ecx: (addr stream byte) <- address stream-storage
|
||||||
write stream, "look up "
|
write stream, "look up "
|
||||||
var sym2/eax: (addr cell) <- copy sym
|
var sym2/eax: (addr cell) <- copy sym
|
||||||
|
@ -423,7 +431,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell)
|
||||||
var error?/eax: boolean <- has-errors? trace
|
var error?/eax: boolean <- has-errors? trace
|
||||||
compare error?, 0/false
|
compare error?, 0/false
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var stream-storage: (stream byte 0x40)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/ecx: (addr stream byte) <- address stream-storage
|
var stream/ecx: (addr stream byte) <- address stream-storage
|
||||||
write stream, "=> "
|
write stream, "=> "
|
||||||
print-cell out, stream, 0/no-trace
|
print-cell out, stream, 0/no-trace
|
||||||
|
@ -473,7 +481,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell)
|
||||||
var error?/eax: boolean <- has-errors? trace
|
var error?/eax: boolean <- has-errors? trace
|
||||||
compare error?, 0/false
|
compare error?, 0/false
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var stream-storage: (stream byte 0x40)
|
var stream-storage: (stream byte 0x200)
|
||||||
var stream/ecx: (addr stream byte) <- address stream-storage
|
var stream/ecx: (addr stream byte) <- address stream-storage
|
||||||
write stream, "=> "
|
write stream, "=> "
|
||||||
print-cell out, stream, 0/no-trace
|
print-cell out, stream, 0/no-trace
|
||||||
|
@ -495,7 +503,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell)
|
||||||
var error?/eax: boolean <- has-errors? trace
|
var error?/eax: boolean <- has-errors? trace
|
||||||
compare error?, 0/false
|
compare error?, 0/false
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var stream-storage: (stream byte 0x40)
|
var stream-storage: (stream byte 0x100)
|
||||||
var stream/ecx: (addr stream byte) <- address stream-storage
|
var stream/ecx: (addr stream byte) <- address stream-storage
|
||||||
write stream, "=> "
|
write stream, "=> "
|
||||||
print-cell out, stream, 0/no-trace
|
print-cell out, stream, 0/no-trace
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn initialize-sandbox _self: (addr sandbox), screen-and-keyboard?: boolean {
|
||||||
var trace-ah/eax: (addr handle trace) <- get self, trace
|
var trace-ah/eax: (addr handle trace) <- get self, trace
|
||||||
allocate trace-ah
|
allocate trace-ah
|
||||||
var trace/eax: (addr trace) <- lookup *trace-ah
|
var trace/eax: (addr trace) <- lookup *trace-ah
|
||||||
initialize-trace trace, 0x1000/lines, 0x80/visible-lines
|
initialize-trace trace, 0x4000/lines, 0x80/visible-lines
|
||||||
var cursor-in-data?/eax: (addr boolean) <- get self, cursor-in-data?
|
var cursor-in-data?/eax: (addr boolean) <- get self, cursor-in-data?
|
||||||
copy-to *cursor-in-data?, 1/true
|
copy-to *cursor-in-data?, 1/true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user