Skip to content

Commit

Permalink
6792
Browse files Browse the repository at this point in the history
Roll back all buffering of Stdout.
  • Loading branch information
akkartik committed Sep 16, 2020
1 parent 9f8f273 commit 9b873e3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
64 changes: 25 additions & 39 deletions 304screen.subx
Expand Up @@ -124,8 +124,7 @@ print-string-to-real-screen: # s: (addr array byte)
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout *(ebp+8))
#? (flush Stdout)
(write 1 *(ebp+8))
$print-string-to-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -138,7 +137,7 @@ print-slice-to-real-screen: # s: (addr slice)
89/<- %ebp 4/r32/esp
#
(write-slice-buffered Stdout *(ebp+8))
#? (flush Stdout)
(flush Stdout)
$print-slice-to-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -151,7 +150,7 @@ print-stream-to-real-screen: # s: (addr stream byte)
89/<- %ebp 4/r32/esp
#
(write-stream-data Stdout *(ebp+8))
#? (flush Stdout)
(flush Stdout)
$print-stream-to-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand Down Expand Up @@ -213,8 +212,7 @@ print-byte-to-real-screen: # c: byte
ff 6/subop/push *(ebp+8)
68/push 1/imm32/size
89/<- %ecx 4/r32/esp
(write-buffered Stdout %ecx)
#? (flush Stdout)
(write 1 %ecx)
$print-byte-to-real-screen:end:
# . reclaim locals
81 0/subop/add %esp 8/imm32
Expand All @@ -225,17 +223,13 @@ $print-byte-to-real-screen:end:
5d/pop-to-ebp
c3/return

flush-stdout:
(flush Stdout)
c3/return

print-int32-hex-to-real-screen: # n: int
# . prologue
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-int32-hex-buffered Stdout *(ebp+8))
#? (flush Stdout)
(flush Stdout)
$print-int32-hex-to-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -248,7 +242,7 @@ print-int32-decimal-to-real-screen: # n: int
89/<- %ebp 4/r32/esp
#
(write-int32-decimal-buffered Stdout *(ebp+8))
#? (flush Stdout)
(flush Stdout)
$print-int32-decimal-to-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand Down Expand Up @@ -284,11 +278,10 @@ reset-formatting-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "(B")
(write-buffered Stdout Esc)
(write-buffered Stdout "[m")
(flush Stdout)
(write 1 Esc)
(write 1 "(B")
(write 1 Esc)
(write 1 "[m")
$reset-formatting-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand Down Expand Up @@ -319,8 +312,7 @@ start-color-on-real-screen: # fg: int, bg: int
(write-int32-decimal %ecx *(ebp+0xc))
(write %ecx "m")
# flush
(write-stream-data Stdout %ecx)
(flush Stdout)
(write-stream 2 %ecx)
$start-color-on-real-screen:end:
# . reclaim locals
81 0/subop/add %esp 0x2c/imm32
Expand All @@ -336,9 +328,8 @@ start-bold-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[1m")
(flush Stdout)
(write 1 Esc)
(write 1 "[1m")
$start-bold-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -350,9 +341,8 @@ start-underline-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[4m")
(flush Stdout)
(write 1 Esc)
(write 1 "[4m")
$start-underline-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -364,9 +354,8 @@ start-reverse-video-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[7m")
(flush Stdout)
(write 1 Esc)
(write 1 "[7m")
$start-reverse-video-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -379,9 +368,8 @@ start-blinking-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[5m")
(flush Stdout)
(write 1 Esc)
(write 1 "[5m")
$start-blinking-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -393,9 +381,8 @@ hide-cursor-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[?25l")
(flush Stdout)
(write 1 Esc)
(write 1 "[?25l")
$hide-cursor-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand All @@ -407,11 +394,10 @@ show-cursor-on-real-screen:
55/push-ebp
89/<- %ebp 4/r32/esp
#
(write-buffered Stdout Esc)
(write-buffered Stdout "[?12l")
(write-buffered Stdout Esc)
(write-buffered Stdout "[?25h")
(flush Stdout)
(write 1 Esc)
(write 1 "[?12l")
(write 1 Esc)
(write 1 "[?25h")
$show-cursor-on-real-screen:end:
# . epilogue
89/<- %esp 5/r32/ebp
Expand Down
2 changes: 0 additions & 2 deletions 400.mu
Expand Up @@ -172,5 +172,3 @@ sig stream-empty? s: (addr stream _) -> result/eax: boolean
sig stream-full? s: (addr stream _) -> result/eax: boolean

sig copy-bytes src: (addr byte), dest: (addr byte), n: int

sig flush-stdout
1 change: 0 additions & 1 deletion apps/tile/main.mu
Expand Up @@ -75,5 +75,4 @@ fn render screen: (addr screen), buf: (addr gap-buffer) {
move-cursor screen, start-row, start-col
#
render-gap-buffer screen, buf
flush-stdout
}
3 changes: 1 addition & 2 deletions apps/tui.mu
Expand Up @@ -28,8 +28,7 @@ fn main -> exit-status/ebx: int {
enable-screen-type-mode
print-string 0, "You pressed "
var x-int/eax: int <- copy x
print-int32-hex-to-real-screen x-int
print-int32-hex 0, x-int
print-string 0, "\n"
flush-stdout
exit-status <- copy 0
}

0 comments on commit 9b873e3

Please sign in to comment.