6699 - start building out fake screen

We now have all existing apps and prototypes going through the dependency-injected
wrapper, even though it doesn't actually implement the fake screen yet.
This commit is contained in:
Kartik Agaram 2020-08-01 23:06:41 -07:00
parent 59a2e363f5
commit 6b343a82f2
66 changed files with 705 additions and 442 deletions

View File

@ -14,7 +14,7 @@ enable-screen-grid-mode:
(write 2 Esc) (write 2 Esc)
(write 2 "[?1049h") (write 2 "[?1049h")
# #
(clear-screen) (clear-real-screen)
$enable-screen-grid-mode:end: $enable-screen-grid-mode:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
@ -34,7 +34,7 @@ $enable-screen-type-mode:end:
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
screen-size: # -> nrows/eax: int, ncols/ecx: int real-screen-size: # -> nrows/eax: int, ncols/ecx: int
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -59,7 +59,7 @@ screen-size: # -> nrows/eax: int, ncols/ecx: int
81 4/subop/and %eax 0xffff/imm32 81 4/subop/and %eax 0xffff/imm32
8b/-> *esi 1/r32/ecx 8b/-> *esi 1/r32/ecx
c1/shift 5/subop/logical-right %ecx 0x10/imm8 c1/shift 5/subop/logical-right %ecx 0x10/imm8
$screen-size:end: $real-screen-size:end:
# . reclaim locals # . reclaim locals
81 0/subop/add %esp 0x40/imm32 81 0/subop/add %esp 0x40/imm32
# . restore registers # . restore registers
@ -72,7 +72,7 @@ $screen-size:end:
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
clear-screen: clear-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -81,14 +81,14 @@ clear-screen:
(write 2 "[H") (write 2 "[H")
(write 2 Esc) (write 2 Esc)
(write 2 "[2J") (write 2 "[2J")
$clear-screen:end: $clear-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
# row and col count from the top-left as (1, 1) # row and col count from the top-left as (1, 1)
move-cursor-on-screen: # row: int, column: int move-cursor-on-real-screen: # row: int, column: int
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -109,7 +109,7 @@ move-cursor-on-screen: # row: int, column: int
(write %ecx "H") (write %ecx "H")
# flush # flush
(write-stream 2 %ecx) (write-stream 2 %ecx)
$move-cursor-on-screen:end: $move-cursor-on-real-screen:end:
# . reclaim locals # . reclaim locals
81 0/subop/add %esp 0x2c/imm32 81 0/subop/add %esp 0x2c/imm32
# . restore registers # . restore registers
@ -119,19 +119,19 @@ $move-cursor-on-screen:end:
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
print-string-to-screen: # s: (addr array byte) print-string-to-real-screen: # s: (addr array byte)
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 *(ebp+8)) (write 2 *(ebp+8))
$print-string-to-screen:end: $print-string-to-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
print-byte-to-screen: # c: byte print-byte-to-real-screen: # c: byte
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -142,7 +142,7 @@ print-byte-to-screen: # c: byte
68/push 4/imm32/size 68/push 4/imm32/size
89/<- %ecx 4/r32/esp 89/<- %ecx 4/r32/esp
(write 2 %ecx) (write 2 %ecx)
$print-byte-to-screen:end: $print-byte-to-real-screen:end:
# . reclaim locals # . reclaim locals
81 0/subop/add %esp 8/imm32 81 0/subop/add %esp 8/imm32
# . restore registers # . restore registers
@ -152,20 +152,20 @@ $print-byte-to-screen:end:
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
print-int32-hex-to-screen: # n: int print-int32-hex-to-real-screen: # n: int
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write-int32-hex-buffered Stdout *(ebp+8)) (write-int32-hex-buffered Stdout *(ebp+8))
(flush Stdout) (flush Stdout)
$print-int32-hex-to-screen:end: $print-int32-hex-to-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
reset-formatting-on-screen: reset-formatting-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -174,13 +174,13 @@ reset-formatting-on-screen:
(write 2 "(B") (write 2 "(B")
(write 2 Esc) (write 2 Esc)
(write 2 "[m") (write 2 "[m")
$reset-formatting-on-screen:end: $reset-formatting-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
start-color-on-screen: # fg: int, bg: int start-color-on-real-screen: # fg: int, bg: int
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -205,7 +205,7 @@ start-color-on-screen: # fg: int, bg: int
(write %ecx "m") (write %ecx "m")
# flush # flush
(write-stream 2 %ecx) (write-stream 2 %ecx)
$start-color-on-screen:end: $start-color-on-real-screen:end:
# . reclaim locals # . reclaim locals
81 0/subop/add %esp 0x2c/imm32 81 0/subop/add %esp 0x2c/imm32
# . restore registers # . restore registers
@ -215,73 +215,73 @@ $start-color-on-screen:end:
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
start-bold-on-screen: start-bold-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 Esc) (write 2 Esc)
(write 2 "[1m") (write 2 "[1m")
$start-bold-on-screen:end: $start-bold-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
start-underline-on-screen: start-underline-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 Esc) (write 2 Esc)
(write 2 "[4m") (write 2 "[4m")
$start-underline-on-screen:end: $start-underline-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
start-reverse-video-on-screen: start-reverse-video-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 Esc) (write 2 Esc)
(write 2 "[7m") (write 2 "[7m")
$start-reverse-video-on-screen:end: $start-reverse-video-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
# might require enabling blinking in your terminal program # might require enabling blinking in your terminal program
start-blinking-on-screen: start-blinking-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 Esc) (write 2 Esc)
(write 2 "[5m") (write 2 "[5m")
$start-blinking-on-screen:end: $start-blinking-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
hide-cursor-on-screen: hide-cursor-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
# #
(write 2 Esc) (write 2 Esc)
(write 2 "[?25l") (write 2 "[?25l")
$hide-cursor-on-screen:end: $hide-cursor-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp
c3/return c3/return
show-cursor-on-screen: show-cursor-on-real-screen:
# . prologue # . prologue
55/push-ebp 55/push-ebp
89/<- %ebp 4/r32/esp 89/<- %ebp 4/r32/esp
@ -290,7 +290,7 @@ show-cursor-on-screen:
(write 2 "[?12l") (write 2 "[?12l")
(write 2 Esc) (write 2 Esc)
(write 2 "[?25h") (write 2 "[?25h")
$show-cursor-on-screen:end: $show-cursor-on-real-screen:end:
# . epilogue # . epilogue
89/<- %esp 5/r32/ebp 89/<- %esp 5/r32/ebp
5d/pop-to-ebp 5d/pop-to-ebp

32
400.mu
View File

@ -116,8 +116,8 @@ sig emit out: (addr buffered-file), word: (addr slice), width: int
#sig get-or-insert table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int, ad: (addr allocation-descriptor) -> result/eax: (addr T) #sig get-or-insert table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int, ad: (addr allocation-descriptor) -> result/eax: (addr T)
#sig get-or-insert-handle table: (addr stream {(handle array byte), T}), key: (handle array byte), row-size: int -> result/eax: (addr T) #sig get-or-insert-handle table: (addr stream {(handle array byte), T}), key: (handle array byte), row-size: int -> result/eax: (addr T)
#sig get-or-insert-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int, ad: (addr allocation-descriptor) -> result/eax: (addr T) #sig get-or-insert-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int, ad: (addr allocation-descriptor) -> result/eax: (addr T)
#sig get-or-stop table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int, #sig get-or-stop table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int
#sig get-slice-or-stop table: (addr stream {(handle array byte), _}), key: (addr slice), row-size: int, #sig get-slice-or-stop table: (addr stream {(handle array byte), _}), key: (addr slice), row-size: int
#sig maybe-get table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int -> result/eax: (addr T) #sig maybe-get table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int -> result/eax: (addr T)
#sig maybe-get-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int -> result/eax: (addr T) #sig maybe-get-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int -> result/eax: (addr T)
sig slurp f: (addr buffered-file), s: (addr stream byte) sig slurp f: (addr buffered-file), s: (addr stream byte)
@ -138,20 +138,20 @@ sig kernel-string-to-string ad: (addr allocation-descriptor), in: (addr kernel-s
sig kernel-string-length in: (addr kernel-string) -> result/eax: int sig kernel-string-length in: (addr kernel-string) -> result/eax: int
sig enable-screen-grid-mode sig enable-screen-grid-mode
sig enable-screen-type-mode sig enable-screen-type-mode
sig screen-size -> nrows/eax: int, ncols/ecx: int sig real-screen-size -> nrows/eax: int, ncols/ecx: int
sig clear-screen sig clear-real-screen
sig move-cursor-on-screen row: int, column: int sig move-cursor-on-real-screen row: int, column: int
sig print-string-to-screen s: (addr array byte) sig print-string-to-real-screen s: (addr array byte)
sig print-byte-to-screen c: byte sig print-byte-to-real-screen c: byte
sig print-int32-hex-to-screen n: int sig print-int32-hex-to-real-screen n: int
sig reset-formatting-on-screen sig reset-formatting-on-real-screen
sig start-color-on-screen fg: int, bg: int sig start-color-on-real-screen fg: int, bg: int
sig start-bold-on-screen sig start-bold-on-real-screen
sig start-underline-on-screen sig start-underline-on-real-screen
sig start-reverse-video-on-screen sig start-reverse-video-on-real-screen
sig start-blinking-on-screen sig start-blinking-on-real-screen
sig hide-cursor-on-screen sig hide-cursor-on-real-screen
sig show-cursor-on-screen sig show-cursor-on-real-screen
sig enable-keyboard-immediate-mode sig enable-keyboard-immediate-mode
sig enable-keyboard-type-mode sig enable-keyboard-type-mode
sig read-key -> result/eax: byte sig read-key -> result/eax: byte

263
404screen.mu Normal file
View File

@ -0,0 +1,263 @@
# Wrappers for real screen primitives that can be passed in a fake screen.
type screen {
num-rows: int
num-cols: int
data: (handle array screen-cell)
pending-scroll?: boolean
top-index: int
cursor-row: int
cursor-col: int
cursor-hide?: boolean
curr-attributes: screen-cell
}
type screen-cell {
color: int
background-color: int
bold?: boolean
underline?: boolean
reverse?: boolean
blink?: boolean
}
fn initialize-screen screen: (addr screen), nrows: int, ncols: int {
var screen-addr/esi: (addr screen) <- copy screen
var tmp/eax: int <- copy 0
var dest/edi: (addr int) <- copy 0
# screen->num-rows = nrows
dest <- get screen-addr, num-rows
tmp <- copy nrows
copy-to *dest, tmp
# screen->num-cols = ncols
dest <- get screen-addr, num-cols
tmp <- copy ncols
copy-to *dest, tmp
# screen->data = new screen-cell[nrows*ncols]
{
var data-addr/edi: (addr handle array screen-cell) <- get screen-addr, data
tmp <- multiply nrows
populate data-addr, tmp
}
# screen->cursor-row = 1
dest <- get screen-addr, cursor-row
copy-to *dest, 1
# screen->cursor-col = 1
dest <- get screen-addr, cursor-col
copy-to *dest, 1
}
fn screen-size screen: (addr screen) -> nrows/eax: int, ncols/ecx: int {
$screen-size:body: {
compare screen, 0
{
break-if-!=
nrows, ncols <- real-screen-size
break $screen-size:body
}
{
break-if-=
# fake screen
var screen-addr/esi: (addr screen) <- copy screen
var tmp/edx: (addr int) <- get screen-addr, num-rows
nrows <- copy *tmp
tmp <- get screen-addr, num-cols
ncols <- copy *tmp
}
}
}
fn clear-screen screen: (addr screen) {
$clear-screen:body: {
compare screen, 0
{
break-if-!=
clear-real-screen
break $clear-screen:body
}
{
break-if-=
# fake screen
}
}
}
fn move-cursor screen: (addr screen), row: int, column: int {
$move-cursor:body: {
compare screen, 0
{
break-if-!=
move-cursor-on-real-screen row, column
break $move-cursor:body
}
{
break-if-=
# fake screen
}
}
}
fn print-string screen: (addr screen), s: (addr array byte) {
$print-string:body: {
compare screen, 0
{
break-if-!=
print-string-to-real-screen s
break $print-string:body
}
{
break-if-=
# fake screen
}
}
}
fn print-byte screen: (addr screen), c: byte {
$print-byte:body: {
compare screen, 0
{
break-if-!=
print-byte-to-real-screen c
break $print-byte:body
}
{
break-if-=
# fake screen
}
}
}
fn print-int32-hex screen: (addr screen), n: int {
$print-int32-hex:body: {
compare screen, 0
{
break-if-!=
print-int32-hex-to-real-screen n
break $print-int32-hex:body
}
{
break-if-=
# fake screen
}
}
}
fn reset-formatting screen: (addr screen) {
$reset-formatting:body: {
compare screen, 0
{
break-if-!=
reset-formatting-on-real-screen
break $reset-formatting:body
}
{
break-if-=
# fake screen
}
}
}
fn start-color screen: (addr screen), fg: int, bg: int {
$start-color:body: {
compare screen, 0
{
break-if-!=
start-color-on-real-screen fg, bg
break $start-color:body
}
{
break-if-=
# fake screen
}
}
}
fn start-bold screen: (addr screen) {
$start-bold:body: {
compare screen, 0
{
break-if-!=
start-bold-on-real-screen
break $start-bold:body
}
{
break-if-=
# fake screen
}
}
}
fn start-underline screen: (addr screen) {
$start-underline:body: {
compare screen, 0
{
break-if-!=
start-underline-on-real-screen
break $start-underline:body
}
{
break-if-=
# fake screen
}
}
}
fn start-reverse-video screen: (addr screen) {
$start-reverse-video:body: {
compare screen, 0
{
break-if-!=
start-reverse-video-on-real-screen
break $start-reverse-video:body
}
{
break-if-=
# fake screen
}
}
}
fn start-blinking screen: (addr screen) {
$start-blinking:body: {
compare screen, 0
{
break-if-!=
start-blinking-on-real-screen
break $start-blinking:body
}
{
break-if-=
# fake screen
}
}
}
fn hide-cursor screen: (addr screen) {
$hide-cursor:body: {
compare screen, 0
{
break-if-!=
hide-cursor-on-real-screen
break $hide-cursor:body
}
{
break-if-=
# fake screen
}
}
}
fn show-cursor screen: (addr screen) {
$show-cursor:body: {
compare screen, 0
{
break-if-!=
show-cursor-on-real-screen
break $show-cursor:body
}
{
break-if-=
# fake screen
}
}
}

View File

@ -35,19 +35,19 @@
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
var look/esi: byte <- copy 0 # lookahead var look/esi: byte <- copy 0 # lookahead
var n/eax: int <- copy 0 # result of each expression var n/eax: int <- copy 0 # result of each expression
print-string-to-screen "press ctrl-c or ctrl-d to exit\n" print-string 0, "press ctrl-c or ctrl-d to exit\n"
# read-eval-print loop # read-eval-print loop
{ {
# print prompt # print prompt
print-string-to-screen "> " print-string 0, "> "
# read and eval # read and eval
n, look <- simplify # we explicitly thread 'look' everywhere n, look <- simplify # we explicitly thread 'look' everywhere
# if (look == 0) break # if (look == 0) break
compare look, 0 compare look, 0
break-if-= break-if-=
# print # print
print-int32-hex-to-screen n print-int32-hex 0, n
print-string-to-screen "\n" print-string 0, "\n"
# #
loop loop
} }
@ -249,7 +249,7 @@ fn get-char -> look/esi: byte {
compare look, 0 compare look, 0
{ {
break-if-!= break-if-!=
print-string-to-screen "^D\n" print-string 0, "^D\n"
syscall_exit syscall_exit
} }
} }

View File

@ -30,7 +30,7 @@ fn main args-on-stack: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -65,7 +65,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -86,7 +86,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -96,7 +96,7 @@ $line-loop: {
update-attributes c, r update-attributes c, r
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} }
@ -116,7 +116,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' # r->current-state == 0 && c == '*'
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -124,7 +124,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' # r->current-state == 0 && c == '_'
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -136,7 +136,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' # r->current-state == 1 && c == '*'
reset-formatting-on-screen reset-formatting 0
copy-to *state, 0 copy-to *state, 0
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -144,7 +144,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' # r->current-state == 1 && c == '_'
reset-formatting-on-screen reset-formatting 0
copy-to *state, 0 copy-to *state, 0
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -159,11 +159,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -176,6 +176,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -14,7 +14,7 @@ $main-body: {
compare n, 1 compare n, 1
{ {
break-if-> break-if->
print-string-to-screen "usage: parse-int <integer>\n" print-string 0, "usage: parse-int <integer>\n"
exit-status <- copy 1 exit-status <- copy 1
break $main-body break $main-body
} }

View File

@ -14,7 +14,7 @@ $main-body: {
compare n, 1 compare n, 1
{ {
break-if-> break-if->
print-string-to-screen "usage: cat <filename>\n" print-string 0, "usage: cat <filename>\n"
break $main-body break $main-body
} }
{ {
@ -31,7 +31,7 @@ $main-body: {
var c/eax: byte <- read-byte-buffered in-addr var c/eax: byte <- read-byte-buffered in-addr
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }
} }

View File

@ -7,28 +7,28 @@
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-screen-grid-mode enable-screen-grid-mode
move-cursor-on-screen 5, 0x22 move-cursor 0, 5, 0x22
start-color-on-screen 1, 0x7a start-color 0, 1, 0x7a
start-blinking-on-screen start-blinking 0
print-string-to-screen "Hello world!" print-string 0, "Hello world!"
reset-formatting-on-screen reset-formatting 0
move-cursor-on-screen 6, 0x22 move-cursor 0, 6, 0x22
print-string-to-screen "tty dimensions: " print-string 0, "tty dimensions: "
print-int32-hex-to-screen nrows print-int32-hex 0, nrows
print-string-to-screen " rows, " print-string 0, " rows, "
print-int32-hex-to-screen ncols print-int32-hex 0, ncols
print-string-to-screen " rows\n" print-string 0, " rows\n"
print-string-to-screen "press a key to see its code: " print-string 0, "press a key to see its code: "
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
var x/eax: byte <- read-key var x/eax: byte <- read-key
enable-keyboard-type-mode enable-keyboard-type-mode
enable-screen-type-mode enable-screen-type-mode
print-string-to-screen "You pressed " print-string 0, "You pressed "
var x-int/eax: int <- copy x var x-int/eax: int <- copy x
print-int32-hex-to-screen x-int print-int32-hex 0, x-int
print-string-to-screen "\n" print-string 0, "\n"
exit-status <- copy 0 exit-status <- copy 0
} }

View File

@ -26,7 +26,7 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }
} }

View File

@ -9,7 +9,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -44,7 +44,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -64,7 +64,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -75,7 +75,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -95,7 +95,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $check-state break $check-state
} }
@ -103,7 +103,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $check-state break $check-state
} }
@ -115,7 +115,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => normal text # r->current-state == 1 && c == '*' => normal text
reset-formatting-on-screen reset-formatting 0
copy-to *state, 0 copy-to *state, 0
break $check-state break $check-state
} }
@ -123,7 +123,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => normal text # r->current-state == 1 && c == '_' => normal text
reset-formatting-on-screen reset-formatting 0
copy-to *state, 0 copy-to *state, 0
break $check-state break $check-state
} }
@ -138,11 +138,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -171,6 +171,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -7,7 +7,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -42,7 +42,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -64,7 +64,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
$char-loop: { $char-loop: {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -79,7 +79,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -87,7 +87,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -99,8 +99,8 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => normal text # r->current-state == 1 && c == '*' => normal text
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -108,8 +108,8 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => normal text # r->current-state == 1 && c == '_' => normal text
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -119,7 +119,7 @@ $update-attributes:check-state: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -134,11 +134,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -167,6 +167,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -6,7 +6,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -41,7 +41,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -63,7 +63,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
$char-loop: { $char-loop: {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -78,7 +78,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -86,7 +86,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -98,10 +98,10 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => print c, then normal text # r->current-state == 1 && c == '*' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -109,10 +109,10 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => print c, then normal text # r->current-state == 1 && c == '_' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -122,7 +122,7 @@ $update-attributes:check-state: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -137,11 +137,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -170,6 +170,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -6,7 +6,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -41,7 +41,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -63,7 +63,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
$char-loop: { $char-loop: {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -78,7 +78,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -86,7 +86,7 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $update-attributes:check-state break $update-attributes:check-state
} }
@ -99,10 +99,10 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => print c, then normal text # r->current-state == 1 && c == '*' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -110,10 +110,10 @@ $update-attributes:check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => print c, then normal text # r->current-state == 1 && c == '_' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -123,7 +123,7 @@ $update-attributes:check-state: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -138,11 +138,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -171,6 +171,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -4,7 +4,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -39,7 +39,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -61,7 +61,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
$char-loop: { $char-loop: {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -76,7 +76,7 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $change-state break $change-state
} }
@ -84,7 +84,7 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $change-state break $change-state
} }
@ -97,10 +97,10 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => print c, then normal text # r->current-state == 1 && c == '*' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -108,10 +108,10 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => print c, then normal text # r->current-state == 1 && c == '_' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -121,7 +121,7 @@ $change-state: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -136,11 +136,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -169,6 +169,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -9,7 +9,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -49,7 +49,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -71,7 +71,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
$char-loop: { $char-loop: {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -86,7 +86,7 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $change-state break $change-state
} }
@ -94,7 +94,7 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '_' => bold text # r->current-state == 0 && c == '_' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
break $change-state break $change-state
} }
@ -121,10 +121,10 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => print c, then normal text # r->current-state == 1 && c == '*' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -132,10 +132,10 @@ $change-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '_' => print c, then normal text # r->current-state == 1 && c == '_' => print c, then normal text
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
copy-to *state, 0 copy-to *state, 0
loop $char-loop loop $char-loop
} }
@ -150,8 +150,8 @@ $change-state: {
var s/eax: (addr boolean) <- get r, start-of-line? var s/eax: (addr boolean) <- get r, start-of-line?
copy-to *s, 1 # true copy-to *s, 1 # true
# switch to normal text # switch to normal text
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
# no need to print newlines # no need to print newlines
break $char-loop break $char-loop
} }
@ -163,7 +163,7 @@ $change-state: {
copy-to *s, 0 # false copy-to *s, 0 # false
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} }
@ -178,11 +178,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -211,6 +211,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -26,7 +26,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var screen-position-state-storage: screen-position-state var screen-position-state-storage: screen-position-state
var screen-position-state: (addr screen-position-state) var screen-position-state: (addr screen-position-state)
init-screen-position-state screen-position-state, nrows, ncols init-screen-position-state screen-position-state, nrows, ncols
@ -68,8 +68,8 @@ fn render-normal in: (addr buffered-file), state: (addr screen-position-state) {
# if (c == EOF) break # if (c == EOF) break
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
# if (c == '*') start-bold-on-screen, render-until-asterisk(in, state), reset # if (c == '*') start-bold 0,, render-until-asterisk(in, state), reset
# else if (c == '_') start-bold-on-screen, render-until-underscore(in, state), reset # else if (c == '_') start-bold 0,, render-until-underscore(in, state), reset
# else if (c == '#') compute-color, start color, render-header-line(in, state), reset # else if (c == '#') compute-color, start color, render-header-line(in, state), reset
# else add-char(state, c) # else add-char(state, c)
} }
@ -183,6 +183,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -28,6 +28,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -10,7 +10,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
# initialize screen state from screen size # initialize screen state from screen size
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var screen-position-state-storage: screen-position-state var screen-position-state-storage: screen-position-state
var screen-position-state: (addr screen-position-state) var screen-position-state: (addr screen-position-state)
init-screen-position-state screen-position-state, nrows, ncols init-screen-position-state screen-position-state, nrows, ncols
@ -44,8 +44,8 @@ fn render-normal fs: (addr file-state), state: (addr screen-position-state) {
# if (c == EOF) break # if (c == EOF) break
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
# if (c == '*') start-bold-on-screen, render-until-asterisk(fs, state), reset # if (c == '*') start-bold 0,, render-until-asterisk(fs, state), reset
# else if (c == '_') start-bold-on-screen, render-until-underscore(fs, state), reset # else if (c == '_') start-bold 0,, render-until-underscore(fs, state), reset
# else if (c == '#' and fs is at start of line) compute-color, start color, render-header-line(fs, state), reset # else if (c == '#' and fs is at start of line) compute-color, start color, render-header-line(fs, state), reset
# else add-char(state, c) # else add-char(state, c)
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -19,7 +19,7 @@ fn render-normal fs: (addr file-state) {
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
# #
print-byte-to-screen c print-byte 0, c
# #
loop loop
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -18,7 +18,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -63,7 +63,7 @@ fn start-drawing _self: (addr screen-position-state) {
fn add-char _self: (addr screen-position-state), c: byte { fn add-char _self: (addr screen-position-state), c: byte {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -131,5 +131,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -25,7 +25,7 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -18,7 +18,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -71,7 +71,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -140,5 +140,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -70,7 +70,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -139,5 +139,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -70,7 +70,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -159,5 +159,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -71,7 +71,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -160,5 +160,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -43,7 +43,7 @@ $render-normal:body: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
loop $render-normal:body loop $render-normal:body
@ -52,11 +52,11 @@ $render-normal:body: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
loop $render-normal:body loop $render-normal:body
} }
# #
@ -115,6 +115,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -71,7 +71,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -160,5 +160,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -87,7 +87,7 @@ $render-normal:flush-buffered-newline: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
loop $render-normal:loop loop $render-normal:loop
@ -96,11 +96,11 @@ $render-normal:flush-buffered-newline: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
loop $render-normal:loop loop $render-normal:loop
} }
# #
@ -159,6 +159,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0xa var nrows/eax: int <- copy 0xa
var ncols/ecx: int <- copy 0x20 var ncols/ecx: int <- copy 0x20
nrows, ncols <- screen-size # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below. nrows, ncols <- screen-size 0 # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -72,7 +72,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -167,5 +167,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -96,7 +96,7 @@ $render-normal:flush-buffered-newline: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
loop $render-normal:loop loop $render-normal:loop
@ -105,11 +105,11 @@ $render-normal:flush-buffered-newline: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
loop $render-normal:loop loop $render-normal:loop
} }
# #
@ -169,32 +169,32 @@ $render-header-line:body: {
# colors for a light background, going from bright to dark (meeting up with bold-text) # colors for a light background, going from bright to dark (meeting up with bold-text)
fn start-heading header-level: int { fn start-heading header-level: int {
$start-heading:body: { $start-heading:body: {
start-bold-on-screen start-bold 0
compare header-level, 1 compare header-level, 1
{ {
break-if-!= break-if-!=
start-color-on-screen 0xa0, 7 start-color 0, 0xa0, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 2 compare header-level, 2
{ {
break-if-!= break-if-!=
start-color-on-screen 0x7c, 7 start-color 0, 0x7c, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 3 compare header-level, 3
{ {
break-if-!= break-if-!=
start-color-on-screen 0x58, 7 start-color 0, 0x58, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 4 compare header-level, 4
{ {
break-if-!= break-if-!=
start-color-on-screen 0x34, 7 start-color 0, 0x34, 7
break $start-heading:body break $start-heading:body
} }
start-color-on-screen 0xe8, 7 start-color 0, 0xe8, 7
} }
} }
@ -247,6 +247,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0xa var nrows/eax: int <- copy 0xa
var ncols/ecx: int <- copy 0x20 var ncols/ecx: int <- copy 0x20
nrows, ncols <- screen-size # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below. nrows, ncols <- screen-size 0 # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -72,7 +72,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -167,5 +167,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -103,7 +103,7 @@ $render-normal:flush-buffered-newline: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
loop $render-normal:loop loop $render-normal:loop
@ -112,11 +112,11 @@ $render-normal:flush-buffered-newline: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
loop $render-normal:loop loop $render-normal:loop
} }
# #
@ -176,32 +176,32 @@ $render-header-line:body: {
# colors for a light background, going from bright to dark (meeting up with bold-text) # colors for a light background, going from bright to dark (meeting up with bold-text)
fn start-heading header-level: int { fn start-heading header-level: int {
$start-heading:body: { $start-heading:body: {
start-bold-on-screen start-bold 0
compare header-level, 1 compare header-level, 1
{ {
break-if-!= break-if-!=
start-color-on-screen 0xa0, 7 start-color 0, 0xa0, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 2 compare header-level, 2
{ {
break-if-!= break-if-!=
start-color-on-screen 0x7c, 7 start-color 0, 0x7c, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 3 compare header-level, 3
{ {
break-if-!= break-if-!=
start-color-on-screen 0x58, 7 start-color 0, 0x58, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 4 compare header-level, 4
{ {
break-if-!= break-if-!=
start-color-on-screen 0x34, 7 start-color 0, 0x34, 7
break $start-heading:body break $start-heading:body
} }
start-color-on-screen 0xe8, 7 start-color 0, 0xe8, 7
} }
} }
@ -254,6 +254,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0xa var nrows/eax: int <- copy 0xa
var ncols/ecx: int <- copy 0x20 var ncols/ecx: int <- copy 0x20
nrows, ncols <- screen-size # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below. nrows, ncols <- screen-size 0 # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -72,7 +72,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -167,5 +167,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -104,7 +104,7 @@ $render-normal:flush-buffered-newline: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
break $render-normal:loop-body break $render-normal:loop-body
@ -113,11 +113,11 @@ $render-normal:flush-buffered-newline: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
break $render-normal:loop-body break $render-normal:loop-body
} }
# #
@ -178,32 +178,32 @@ $render-header-line:body: {
# colors for a light background, going from bright to dark (meeting up with bold-text) # colors for a light background, going from bright to dark (meeting up with bold-text)
fn start-heading header-level: int { fn start-heading header-level: int {
$start-heading:body: { $start-heading:body: {
start-bold-on-screen start-bold 0
compare header-level, 1 compare header-level, 1
{ {
break-if-!= break-if-!=
start-color-on-screen 0xa0, 7 start-color 0, 0xa0, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 2 compare header-level, 2
{ {
break-if-!= break-if-!=
start-color-on-screen 0x7c, 7 start-color 0, 0x7c, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 3 compare header-level, 3
{ {
break-if-!= break-if-!=
start-color-on-screen 0x58, 7 start-color 0, 0x58, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 4 compare header-level, 4
{ {
break-if-!= break-if-!=
start-color-on-screen 0x34, 7 start-color 0, 0x34, 7
break $start-heading:body break $start-heading:body
} }
start-color-on-screen 0xe8, 7 start-color 0, 0xe8, 7
} }
} }
@ -256,6 +256,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0xa var nrows/eax: int <- copy 0xa
var ncols/ecx: int <- copy 0x20 var ncols/ecx: int <- copy 0x20
nrows, ncols <- screen-size # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below. nrows, ncols <- screen-size 0 # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -72,7 +72,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -167,5 +167,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -39,6 +39,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -113,7 +113,7 @@ $render-normal:whitespace-separated-regions: {
compare c, 0x2a # '*' compare c, 0x2a # '*'
{ {
break-if-!= break-if-!=
start-bold-on-screen start-bold 0
render-until-asterisk fs, state render-until-asterisk fs, state
normal-text normal-text
break $render-normal:loop-body break $render-normal:loop-body
@ -122,11 +122,11 @@ $render-normal:whitespace-separated-regions: {
compare c, 0x5f # '_' compare c, 0x5f # '_'
{ {
break-if-!= break-if-!=
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
start-bold-on-screen start-bold 0
render-until-underscore fs, state render-until-underscore fs, state
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
break $render-normal:loop-body break $render-normal:loop-body
} }
} }
@ -188,32 +188,32 @@ $render-header-line:body: {
# colors for a light background, going from bright to dark (meeting up with bold-text) # colors for a light background, going from bright to dark (meeting up with bold-text)
fn start-heading header-level: int { fn start-heading header-level: int {
$start-heading:body: { $start-heading:body: {
start-bold-on-screen start-bold 0
compare header-level, 1 compare header-level, 1
{ {
break-if-!= break-if-!=
start-color-on-screen 0xa0, 7 start-color 0, 0xa0, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 2 compare header-level, 2
{ {
break-if-!= break-if-!=
start-color-on-screen 0x7c, 7 start-color 0, 0x7c, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 3 compare header-level, 3
{ {
break-if-!= break-if-!=
start-color-on-screen 0x58, 7 start-color 0, 0x58, 7
break $start-heading:body break $start-heading:body
} }
compare header-level, 4 compare header-level, 4
{ {
break-if-!= break-if-!=
start-color-on-screen 0x34, 7 start-color 0, 0x34, 7
break $start-heading:body break $start-heading:body
} }
start-color-on-screen 0xe8, 7 start-color 0, 0xe8, 7
} }
} }
@ -266,6 +266,6 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
} }
fn normal-text { fn normal-text {
reset-formatting-on-screen reset-formatting 0
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
} }

View File

@ -17,7 +17,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var nrows/eax: int <- copy 0xa var nrows/eax: int <- copy 0xa
var ncols/ecx: int <- copy 0x20 var ncols/ecx: int <- copy 0x20
nrows, ncols <- screen-size # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below. nrows, ncols <- screen-size 0 # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
var dest/edx: (addr int) <- copy 0 var dest/edx: (addr int) <- copy 0
# self->nrows = nrows # self->nrows = nrows
dest <- get self, nrows dest <- get self, nrows
@ -39,7 +39,7 @@ fn start-drawing _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var tmp/eax: (addr int) <- copy 0 var tmp/eax: (addr int) <- copy 0
var tmp2/ecx: int <- copy 0 var tmp2/ecx: int <- copy 0
clear-screen clear-screen 0
# self->leftcol = page-margin # self->leftcol = page-margin
tmp <- get self, leftcol tmp <- get self, leftcol
copy-to *tmp, 5 # left-margin copy-to *tmp, 5 # left-margin
@ -72,7 +72,7 @@ $add-char:body: {
break $add-char:body break $add-char:body
} }
# print c # print c
print-byte-to-screen c print-byte 0, c
# self->col++ # self->col++
var tmp/eax: (addr int) <- get self, col var tmp/eax: (addr int) <- get self, col
increment *tmp increment *tmp
@ -167,5 +167,5 @@ fn reposition-cursor _self: (addr screen-position-state) {
var self/esi: (addr screen-position-state) <- copy _self var self/esi: (addr screen-position-state) <- copy _self
var r/eax: (addr int) <- get self, row var r/eax: (addr int) <- get self, row
var c/ecx: (addr int) <- get self, col var c/ecx: (addr int) <- get self, col
move-cursor-on-screen *r *c move-cursor 0, *r *c
} }

View File

@ -24,6 +24,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -21,7 +21,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -29,7 +29,7 @@ $line-loop: {
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= $line-loop break-if-= $line-loop
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -44,11 +44,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -76,6 +76,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

10
prototypes/browse/5.mu generated
View File

@ -21,7 +21,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -31,7 +31,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -46,11 +46,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -78,6 +78,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

10
prototypes/browse/6.mu generated
View File

@ -32,7 +32,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -42,7 +42,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -57,11 +57,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -89,6 +89,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

12
prototypes/browse/7.mu generated
View File

@ -4,7 +4,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -36,7 +36,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -46,7 +46,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -61,11 +61,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -94,6 +94,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -4,7 +4,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -52,7 +52,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -62,7 +62,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -77,11 +77,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -110,6 +110,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

View File

@ -4,7 +4,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
enable-screen-grid-mode enable-screen-grid-mode
var nrows/eax: int <- copy 0 var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0 var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size nrows, ncols <- screen-size 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
{ {
render file, nrows, ncols render file, nrows, ncols
@ -39,7 +39,7 @@ fn render in: (addr buffered-file), nrows: int, ncols: int {
var leftcol/edx: int <- copy 5 # page-margin var leftcol/edx: int <- copy 5 # page-margin
var rightcol/ebx: int <- copy leftcol var rightcol/ebx: int <- copy leftcol
rightcol <- add 0x40 # page-width = 64 characters rightcol <- add 0x40 # page-width = 64 characters
start-color-on-screen 0xec, 7 # 236 = darkish gray start-color 0, 0xec, 7 # 236 = darkish gray
{ {
compare rightcol, ncols compare rightcol, ncols
break-if->= break-if->=
@ -59,7 +59,7 @@ $line-loop: {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
@ -70,7 +70,7 @@ $line-loop: {
compare c, 0xa # newline compare c, 0xa # newline
break-if-= # no need to print newlines break-if-= # no need to print newlines
# print c # print c
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} # $char-loop } # $char-loop
@ -90,7 +90,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 0 && c == '*' => bold text # r->current-state == 0 && c == '*' => bold text
start-bold-on-screen start-bold 0
copy-to *state, 1 copy-to *state, 1
} }
break $check-state break $check-state
@ -101,7 +101,7 @@ $check-state: {
{ {
break-if-!= break-if-!=
# r->current-state == 1 && c == '*' => normal text # r->current-state == 1 && c == '*' => normal text
reset-formatting-on-screen reset-formatting 0
copy-to *state, 0 copy-to *state, 0
} }
} }
@ -114,11 +114,11 @@ fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
compare row, botrow compare row, botrow
break-if->= break-if->=
var col/edx: int <- copy leftcol var col/edx: int <- copy leftcol
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, rightcol compare col, rightcol
break-if->= break-if->=
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -147,6 +147,6 @@ fn dump in: (addr buffered-file) {
var c/eax: byte <- read-byte-buffered in var c/eax: byte <- read-byte-buffered in
compare c, 0xffffffff # EOF marker compare c, 0xffffffff # EOF marker
break-if-= break-if-=
print-byte-to-screen c print-byte 0, c
loop loop
} }

16
prototypes/tile/1.mu generated
View File

@ -10,9 +10,9 @@
# https://archive.org/details/akkartik-2min-2020-07-01 # https://archive.org/details/akkartik-2min-2020-07-01
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
clear-screen clear-screen 0
move-cursor-on-screen 5, 5 move-cursor 0, 5, 5
print-string-to-screen "_________" print-string 0, "_________"
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
var dummy/eax: byte <- read-key var dummy/eax: byte <- read-key
var row/eax: int <- copy 5 var row/eax: int <- copy 5
@ -26,7 +26,7 @@ fn main -> exit-status/ebx: int {
} }
var dummy/eax: byte <- read-key var dummy/eax: byte <- read-key
enable-keyboard-type-mode enable-keyboard-type-mode
clear-screen clear-screen 0
exit-status <- copy 0 exit-status <- copy 0
} }
@ -35,11 +35,11 @@ fn animate row: int {
{ {
compare col, 0xe compare col, 0xe
break-if-= break-if-=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen " " print-string 0, " "
increment row increment row
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "_" print-string 0, "_"
decrement row decrement row
col <- increment col <- increment
loop loop

28
prototypes/tile/10.mu generated
View File

@ -75,7 +75,7 @@ $main:loop: {
render root-addr, cursor-addr render root-addr, cursor-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -199,7 +199,7 @@ fn create-child node: (handle cell) {
####################################################### #######################################################
fn render root: (addr cell), cursor: (addr cell) { fn render root: (addr cell), cursor: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x65 # col2 var viewport-width/ecx: int <- copy 0x65 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -318,11 +318,11 @@ fn draw-hatching row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -333,8 +333,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }
@ -346,8 +346,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# x = next power-of-2 multiple of _dr after _nr # x = next power-of-2 multiple of _dr after _nr
var x/ecx: int <- copy 1 var x/ecx: int <- copy 1
{ {
#? print-int32-hex-to-screen x #? print-int32-hex 0, x
#? print-string-to-screen "\n" #? print-string 0, "\n"
var tmp/edx: int <- copy _dr var tmp/edx: int <- copy _dr
tmp <- multiply x tmp <- multiply x
compare tmp, _nr compare tmp, _nr
@ -355,7 +355,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
x <- shift-left 1 x <- shift-left 1
loop loop
} }
#? print-string-to-screen "--\n" #? print-string 0, "--\n"
# min, max = x/2, x # min, max = x/2, x
var max/ecx: int <- copy x var max/ecx: int <- copy x
var min/edx: int <- copy max var min/edx: int <- copy max
@ -363,8 +363,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# narrow down result between min and max # narrow down result between min and max
var i/eax: int <- copy min var i/eax: int <- copy min
{ {
#? print-int32-hex-to-screen i #? print-int32-hex 0, i
#? print-string-to-screen "\n" #? print-string 0, "\n"
var foo/ebx: int <- copy _dr var foo/ebx: int <- copy _dr
foo <- multiply i foo <- multiply i
compare foo, _nr compare foo, _nr
@ -374,9 +374,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
} }
result <- copy i result <- copy i
result <- decrement result <- decrement
#? print-string-to-screen "=> " #? print-string 0, "=> "
#? print-int32-hex-to-screen result #? print-int32-hex 0, result
#? print-string-to-screen "\n" #? print-string 0, "\n"
} }
fn test-try-divide-1 { fn test-try-divide-1 {

14
prototypes/tile/2.mu generated
View File

@ -9,7 +9,7 @@
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
var num-lines/ecx: int <- copy 0x10 var num-lines/ecx: int <- copy 0x10
clear-screen clear-screen 0
# open a file # open a file
var f: (addr buffered-file) var f: (addr buffered-file)
{ {
@ -36,7 +36,7 @@ fn main -> exit-status/ebx: int {
enable-keyboard-type-mode enable-keyboard-type-mode
} }
# clean up # clean up
clear-screen clear-screen 0
exit-status <- copy 0 exit-status <- copy 0
} }
@ -48,11 +48,11 @@ $render:clear-loop: {
break-if-<= break-if-<=
decrement start-row decrement start-row
var col/eax: int <- copy 1 var col/eax: int <- copy 1
move-cursor-on-screen start-row, col move-cursor 0, start-row, col
{ {
compare col, num-cols compare col, num-cols
break-if-> break-if->
print-string-to-screen " " print-string 0, " "
col <- increment col <- increment
loop loop
} }
@ -61,7 +61,7 @@ $render:clear-loop: {
# render rest of screen below # render rest of screen below
var row/edx: int <- copy start-row var row/edx: int <- copy start-row
var col/ebx: int <- copy 1 var col/ebx: int <- copy 1
move-cursor-on-screen row, col move-cursor 0, row, col
$render:render-loop: { $render:render-loop: {
compare row, num-rows compare row, num-rows
break-if->= break-if->=
@ -73,10 +73,10 @@ $render:render-loop: {
break-if-!= break-if-!=
row <- increment row <- increment
col <- copy 0 col <- copy 0
move-cursor-on-screen row, col move-cursor 0, row, col
loop $render:render-loop loop $render:render-loop
} }
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} }

22
prototypes/tile/3.mu generated
View File

@ -7,7 +7,7 @@
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
var num-lines/ecx: int <- copy 0x64 # 100 var num-lines/ecx: int <- copy 0x64 # 100
clear-screen clear-screen 0
# open a file # open a file
var f: (addr buffered-file) var f: (addr buffered-file)
{ {
@ -36,14 +36,14 @@ fn main -> exit-status/ebx: int {
var t3/esi: int <- copy t2 var t3/esi: int <- copy t2
t3 <- subtract t1 t3 <- subtract t1
# clean up # clean up
clear-screen clear-screen 0
# results # results
print-int32-hex-to-screen t1 print-int32-hex 0, t1
print-string-to-screen "\n" print-string 0, "\n"
print-int32-hex-to-screen t2 print-int32-hex 0, t2
print-string-to-screen "\n" print-string 0, "\n"
print-int32-hex-to-screen t3 print-int32-hex 0, t3
print-string-to-screen "\n" print-string 0, "\n"
# #
exit-status <- copy 0 exit-status <- copy 0
} }
@ -53,7 +53,7 @@ fn render f: (addr buffered-file), num-rows: int {
# render screen # render screen
var row/edx: int <- copy 1 var row/edx: int <- copy 1
var col/ebx: int <- copy 1 var col/ebx: int <- copy 1
move-cursor-on-screen row, col move-cursor 0, row, col
$render:render-loop: { $render:render-loop: {
compare row, num-rows compare row, num-rows
break-if->= break-if->=
@ -65,10 +65,10 @@ $render:render-loop: {
break-if-!= break-if-!=
row <- increment row <- increment
col <- copy 0 col <- copy 0
move-cursor-on-screen row, col move-cursor 0, row, col
loop $render:render-loop loop $render:render-loop
} }
print-byte-to-screen c print-byte 0, c
col <- increment col <- increment
loop loop
} }

14
prototypes/tile/4.mu generated
View File

@ -7,7 +7,7 @@
# $ ./a.elf # $ ./a.elf
fn main -> exit-status/ebx: int { fn main -> exit-status/ebx: int {
clear-screen clear-screen 0
enable-keyboard-immediate-mode enable-keyboard-immediate-mode
var dummy/eax: byte <- read-key var dummy/eax: byte <- read-key
draw-box 5, 5, 0x23, 0x23 # 35, 35 draw-box 5, 5, 0x23, 0x23 # 35, 35
@ -19,12 +19,12 @@ fn main -> exit-status/ebx: int {
draw-box 5, 5, 0x23, 0xaf # 35, 175 draw-box 5, 5, 0x23, 0xaf # 35, 175
var dummy/eax: byte <- read-key var dummy/eax: byte <- read-key
enable-keyboard-type-mode enable-keyboard-type-mode
clear-screen clear-screen 0
exit-status <- copy 0 exit-status <- copy 0
} }
fn draw-box row1: int, col1: int, row2: int, col2: int { fn draw-box row1: int, col1: int, row2: int, col2: int {
clear-screen clear-screen 0
draw-horizontal-line row1, col1, col2 draw-horizontal-line row1, col1, col2
draw-vertical-line row1, row2, col1 draw-vertical-line row1, row2, col1
draw-horizontal-line row2, col1, col2 draw-horizontal-line row2, col1, col2
@ -33,11 +33,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -48,8 +48,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }

12
prototypes/tile/5.mu generated
View File

@ -41,7 +41,7 @@ $main:loop: {
render root-addr render root-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -67,7 +67,7 @@ fn create-child node: (addr cell) {
####################################################### #######################################################
fn render root: (addr cell) { fn render root: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x64 # col2 var viewport-width/ecx: int <- copy 0x64 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -134,11 +134,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -149,8 +149,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }

30
prototypes/tile/6.mu generated
View File

@ -68,7 +68,7 @@ $main:loop: {
render root-addr render root-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -83,7 +83,7 @@ fn process c: byte, root: (addr handle cell), cursor: (addr handle cell) {
var c2/eax: (addr cell) <- lookup *c1 var c2/eax: (addr cell) <- lookup *c1
var c3/edx: (addr cell) <- copy c2 var c3/edx: (addr cell) <- copy c2
{ {
print-string-to-screen "iter\n" print-string 0, "iter\n"
var tmp/ebx: (addr handle cell) <- get c3, first-child var tmp/ebx: (addr handle cell) <- get c3, first-child
var tmp2/eax: (addr cell) <- lookup *tmp var tmp2/eax: (addr cell) <- lookup *tmp
compare tmp2, 0 compare tmp2, 0
@ -106,7 +106,7 @@ fn create-child node: (addr cell) {
####################################################### #######################################################
fn render root: (addr cell) { fn render root: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x64 # col2 var viewport-width/ecx: int <- copy 0x64 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -161,11 +161,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -176,8 +176,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }
@ -189,8 +189,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# x = next power-of-2 multiple of _dr after _nr # x = next power-of-2 multiple of _dr after _nr
var x/ecx: int <- copy 1 var x/ecx: int <- copy 1
{ {
#? print-int32-hex-to-screen x #? print-int32-hex 0, x
#? print-string-to-screen "\n" #? print-string 0, "\n"
var tmp/edx: int <- copy _dr var tmp/edx: int <- copy _dr
tmp <- multiply x tmp <- multiply x
compare tmp, _nr compare tmp, _nr
@ -198,7 +198,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
x <- shift-left 1 x <- shift-left 1
loop loop
} }
#? print-string-to-screen "--\n" #? print-string 0, "--\n"
# min, max = x/2, x # min, max = x/2, x
var max/ecx: int <- copy x var max/ecx: int <- copy x
var min/edx: int <- copy max var min/edx: int <- copy max
@ -206,8 +206,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# narrow down result between min and max # narrow down result between min and max
var i/eax: int <- copy min var i/eax: int <- copy min
{ {
#? print-int32-hex-to-screen i #? print-int32-hex 0, i
#? print-string-to-screen "\n" #? print-string 0, "\n"
var foo/ebx: int <- copy _dr var foo/ebx: int <- copy _dr
foo <- multiply i foo <- multiply i
compare foo, _nr compare foo, _nr
@ -217,9 +217,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
} }
result <- copy i result <- copy i
result <- decrement result <- decrement
#? print-string-to-screen "=> " #? print-string 0, "=> "
#? print-int32-hex-to-screen result #? print-int32-hex 0, result
#? print-string-to-screen "\n" #? print-string 0, "\n"
} }
fn test-try-divide-1 { fn test-try-divide-1 {

28
prototypes/tile/7.mu generated
View File

@ -72,7 +72,7 @@ $main:loop: {
render root-addr render root-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -105,7 +105,7 @@ fn create-child node: (addr cell) {
####################################################### #######################################################
fn render root: (addr cell) { fn render root: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x64 # col2 var viewport-width/ecx: int <- copy 0x64 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -175,11 +175,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -190,8 +190,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }
@ -203,8 +203,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# x = next power-of-2 multiple of _dr after _nr # x = next power-of-2 multiple of _dr after _nr
var x/ecx: int <- copy 1 var x/ecx: int <- copy 1
{ {
#? print-int32-hex-to-screen x #? print-int32-hex 0, x
#? print-string-to-screen "\n" #? print-string 0, "\n"
var tmp/edx: int <- copy _dr var tmp/edx: int <- copy _dr
tmp <- multiply x tmp <- multiply x
compare tmp, _nr compare tmp, _nr
@ -212,7 +212,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
x <- shift-left 1 x <- shift-left 1
loop loop
} }
#? print-string-to-screen "--\n" #? print-string 0, "--\n"
# min, max = x/2, x # min, max = x/2, x
var max/ecx: int <- copy x var max/ecx: int <- copy x
var min/edx: int <- copy max var min/edx: int <- copy max
@ -220,8 +220,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# narrow down result between min and max # narrow down result between min and max
var i/eax: int <- copy min var i/eax: int <- copy min
{ {
#? print-int32-hex-to-screen i #? print-int32-hex 0, i
#? print-string-to-screen "\n" #? print-string 0, "\n"
var foo/ebx: int <- copy _dr var foo/ebx: int <- copy _dr
foo <- multiply i foo <- multiply i
compare foo, _nr compare foo, _nr
@ -231,9 +231,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
} }
result <- copy i result <- copy i
result <- decrement result <- decrement
#? print-string-to-screen "=> " #? print-string 0, "=> "
#? print-int32-hex-to-screen result #? print-int32-hex 0, result
#? print-string-to-screen "\n" #? print-string 0, "\n"
} }
fn test-try-divide-1 { fn test-try-divide-1 {

28
prototypes/tile/8.mu generated
View File

@ -72,7 +72,7 @@ $main:loop: {
render root-addr render root-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -105,7 +105,7 @@ fn create-child node: (addr cell) {
####################################################### #######################################################
fn render root: (addr cell) { fn render root: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x64 # col2 var viewport-width/ecx: int <- copy 0x64 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -205,11 +205,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -220,8 +220,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }
@ -233,8 +233,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# x = next power-of-2 multiple of _dr after _nr # x = next power-of-2 multiple of _dr after _nr
var x/ecx: int <- copy 1 var x/ecx: int <- copy 1
{ {
#? print-int32-hex-to-screen x #? print-int32-hex 0, x
#? print-string-to-screen "\n" #? print-string 0, "\n"
var tmp/edx: int <- copy _dr var tmp/edx: int <- copy _dr
tmp <- multiply x tmp <- multiply x
compare tmp, _nr compare tmp, _nr
@ -242,7 +242,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
x <- shift-left 1 x <- shift-left 1
loop loop
} }
#? print-string-to-screen "--\n" #? print-string 0, "--\n"
# min, max = x/2, x # min, max = x/2, x
var max/ecx: int <- copy x var max/ecx: int <- copy x
var min/edx: int <- copy max var min/edx: int <- copy max
@ -250,8 +250,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# narrow down result between min and max # narrow down result between min and max
var i/eax: int <- copy min var i/eax: int <- copy min
{ {
#? print-int32-hex-to-screen i #? print-int32-hex 0, i
#? print-string-to-screen "\n" #? print-string 0, "\n"
var foo/ebx: int <- copy _dr var foo/ebx: int <- copy _dr
foo <- multiply i foo <- multiply i
compare foo, _nr compare foo, _nr
@ -261,9 +261,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
} }
result <- copy i result <- copy i
result <- decrement result <- decrement
#? print-string-to-screen "=> " #? print-string 0, "=> "
#? print-int32-hex-to-screen result #? print-int32-hex 0, result
#? print-string-to-screen "\n" #? print-string 0, "\n"
} }
fn test-try-divide-1 { fn test-try-divide-1 {

28
prototypes/tile/9.mu generated
View File

@ -71,7 +71,7 @@ $main:loop: {
render root-addr, cursor-addr render root-addr, cursor-addr
loop loop
} }
clear-screen clear-screen 0
enable-keyboard-type-mode enable-keyboard-type-mode
exit-status <- copy 0 exit-status <- copy 0
} }
@ -183,7 +183,7 @@ fn create-child node: (addr cell) {
####################################################### #######################################################
fn render root: (addr cell), cursor: (addr cell) { fn render root: (addr cell), cursor: (addr cell) {
clear-screen clear-screen 0
var depth/eax: int <- tree-depth root var depth/eax: int <- tree-depth root
var viewport-width/ecx: int <- copy 0x64 # col2 var viewport-width/ecx: int <- copy 0x64 # col2
viewport-width <- subtract 5 # col1 viewport-width <- subtract 5 # col1
@ -283,11 +283,11 @@ fn draw-box row1: int, col1: int, row2: int, col2: int {
fn draw-horizontal-line row: int, col1: int, col2: int { fn draw-horizontal-line row: int, col1: int, col2: int {
var col/eax: int <- copy col1 var col/eax: int <- copy col1
move-cursor-on-screen row, col move-cursor 0, row, col
{ {
compare col, col2 compare col, col2
break-if->= break-if->=
print-string-to-screen "-" print-string 0, "-"
col <- increment col <- increment
loop loop
} }
@ -298,8 +298,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
{ {
compare row, row2 compare row, row2
break-if->= break-if->=
move-cursor-on-screen row, col move-cursor 0, row, col
print-string-to-screen "|" print-string 0, "|"
row <- increment row <- increment
loop loop
} }
@ -311,8 +311,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# x = next power-of-2 multiple of _dr after _nr # x = next power-of-2 multiple of _dr after _nr
var x/ecx: int <- copy 1 var x/ecx: int <- copy 1
{ {
#? print-int32-hex-to-screen x #? print-int32-hex 0, x
#? print-string-to-screen "\n" #? print-string 0, "\n"
var tmp/edx: int <- copy _dr var tmp/edx: int <- copy _dr
tmp <- multiply x tmp <- multiply x
compare tmp, _nr compare tmp, _nr
@ -320,7 +320,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
x <- shift-left 1 x <- shift-left 1
loop loop
} }
#? print-string-to-screen "--\n" #? print-string 0, "--\n"
# min, max = x/2, x # min, max = x/2, x
var max/ecx: int <- copy x var max/ecx: int <- copy x
var min/edx: int <- copy max var min/edx: int <- copy max
@ -328,8 +328,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
# narrow down result between min and max # narrow down result between min and max
var i/eax: int <- copy min var i/eax: int <- copy min
{ {
#? print-int32-hex-to-screen i #? print-int32-hex 0, i
#? print-string-to-screen "\n" #? print-string 0, "\n"
var foo/ebx: int <- copy _dr var foo/ebx: int <- copy _dr
foo <- multiply i foo <- multiply i
compare foo, _nr compare foo, _nr
@ -339,9 +339,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
} }
result <- copy i result <- copy i
result <- decrement result <- decrement
#? print-string-to-screen "=> " #? print-string 0, "=> "
#? print-int32-hex-to-screen result #? print-int32-hex 0, result
#? print-string-to-screen "\n" #? print-string 0, "\n"
} }
fn test-try-divide-1 { fn test-try-divide-1 {