From 8c3ecee4c1d927b6b2a0e05e0415a91a96b1cb7d Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 30 May 2020 00:23:05 -0700 Subject: 6443 --- html/103screen.subx.html | 604 +++++++++++++++++++++---------------------- html/apps/browse.mu.html | 184 +++++++++++++ html/apps/print-file.mu.html | 11 +- 3 files changed, 488 insertions(+), 311 deletions(-) create mode 100644 html/apps/browse.mu.html diff --git a/html/103screen.subx.html b/html/103screen.subx.html index aa84b4d9..29c4d6f9 100644 --- a/html/103screen.subx.html +++ b/html/103screen.subx.html @@ -69,10 +69,10 @@ if ('onhashchange' in window) { 11 (flush Stdout) 12 (flush Stderr) 13 # switch to second screen buffer - 14 (write 2 Esc) + 14 (write 2 Esc) 15 (write 2 "[?1049h") 16 # - 17 (clear-screen) + 17 (clear-screen) 18 $enable-screen-grid-mode:end: 19 # . epilogue 20 89/<- %esp 5/r32/ebp @@ -84,7 +84,7 @@ if ('onhashchange' in window) { 26 55/push-ebp 27 89/<- %ebp 4/r32/esp 28 # switch to first screen buffer - 29 (write 2 Esc) + 29 (write 2 Esc) 30 (write 2 "[?1049l") 31 $enable-screen-type-mode:end: 32 # . epilogue @@ -97,309 +97,303 @@ if ('onhashchange' in window) { 39 55/push-ebp 40 89/<- %ebp 4/r32/esp 41 # . save registers - 42 50/push-eax - 43 51/push-ecx - 44 52/push-edx - 45 53/push-ebx - 46 56/push-esi - 47 57/push-edi - 48 # - 49 (_maybe-open-terminal) - 50 # var window-size-info/esi: (addr winsize) - 51 # winsize is a type from the Linux kernel. We don't care how large it is. - 52 81 5/subop/subtract %esp 0x40/imm32 - 53 89/<- %esi 4/r32/esp - 54 # ioctl(*Terminal-file-descriptor, TIOCGWINSZ, window-size-info) - 55 89/<- %edx 6/r32/esi - 56 b9/copy-to-ecx 0x5413/imm32/TIOCGWINSZ - 57 8b/-> *Terminal-file-descriptor 3/r32/ebx - 58 e8/call syscall_ioctl/disp32 - 59 # some bitworking to extract 2 16-bit shorts - 60 8b/-> *esi 0/r32/eax - 61 81 4/subop/and %eax 0xffff/imm32 - 62 8b/-> *esi 1/r32/ecx - 63 c1/shift 5/subop/logical-right %ecx 0x10/imm8 - 64 $screen-size:end: - 65 # . reclaim locals - 66 81 0/subop/add %esp 0x40/imm32 - 67 # . restore registers - 68 5f/pop-to-edi - 69 5e/pop-to-esi - 70 5b/pop-to-ebx - 71 5a/pop-to-edx - 72 59/pop-to-ecx - 73 58/pop-to-eax - 74 # . epilogue - 75 89/<- %esp 5/r32/ebp - 76 5d/pop-to-ebp - 77 c3/return - 78 - 79 clear-screen: - 80 # . prologue - 81 55/push-ebp - 82 89/<- %ebp 4/r32/esp - 83 # - 84 (write 2 Esc) - 85 (write 2 "[H") - 86 (write 2 Esc) - 87 (write 2 "[2J") - 88 $clear-screen:end: - 89 # . epilogue - 90 89/<- %esp 5/r32/ebp - 91 5d/pop-to-ebp - 92 c3/return - 93 - 94 move-cursor: # row: int, column: int - 95 # . prologue - 96 55/push-ebp - 97 89/<- %ebp 4/r32/esp - 98 # . save registers - 99 51/push-ecx -100 # var buf/ecx: (stream byte 32) -101 81 5/subop/subtract %esp 0x20/imm32 -102 68/push 0x20/imm32/size -103 68/push 0/imm32/read -104 68/push 0/imm32/write -105 89/<- %ecx 4/r32/esp -106 # construct directive in buf -107 (write %ecx Esc) -108 (write %ecx "[") -109 (print-int32-decimal %ecx *(ebp+8)) -110 (write %ecx ";") -111 (print-int32-decimal %ecx *(ebp+0xc)) -112 (write %ecx "H") -113 # flush -114 (write-stream 2 %ecx) -115 $move-cursor:end: -116 # . reclaim locals -117 81 0/subop/add %esp 0x2c/imm32 -118 # . restore registers -119 59/pop-to-ecx -120 # . epilogue -121 89/<- %esp 5/r32/ebp -122 5d/pop-to-ebp -123 c3/return -124 -125 print-string: # s: (addr array byte) -126 # . prologue -127 55/push-ebp -128 89/<- %ebp 4/r32/esp -129 # -130 (write 2 *(ebp+8)) -131 $print-string:end: -132 # . epilogue -133 89/<- %esp 5/r32/ebp -134 5d/pop-to-ebp -135 c3/return -136 -137 # just because Mu has no support for global variables yet -138 print-byte: # c: byte -139 # . prologue -140 55/push-ebp -141 89/<- %ebp 4/r32/esp -142 # -143 (write-byte-buffered Stdout *(ebp+8)) -144 $print-byte:end: -145 # . epilogue -146 89/<- %esp 5/r32/ebp -147 5d/pop-to-ebp -148 c3/return -149 -150 # just because Mu has no support for global variables yet -151 flush-stdout: -152 # . prologue -153 55/push-ebp -154 89/<- %ebp 4/r32/esp -155 # -156 (flush Stdout) -157 $flush-stdout:end: -158 # . epilogue -159 89/<- %esp 5/r32/ebp -160 5d/pop-to-ebp -161 c3/return -162 -163 # just because Mu has no support for global variables yet -164 print-int32-to-screen: # n: int -165 # . prologue -166 55/push-ebp -167 89/<- %ebp 4/r32/esp -168 # -169 (print-int32-buffered Stdout *(ebp+8)) -170 $print-int32-to-screen:end: -171 # . epilogue -172 89/<- %esp 5/r32/ebp -173 5d/pop-to-ebp -174 c3/return -175 -176 reset-formatting: -177 # . prologue -178 55/push-ebp -179 89/<- %ebp 4/r32/esp -180 # -181 (write 2 Esc) -182 (write 2 "(B") -183 (write 2 Esc) -184 (write 2 "[m") -185 $reset-formatting:end: -186 # . epilogue -187 89/<- %esp 5/r32/ebp -188 5d/pop-to-ebp -189 c3/return -190 -191 start-color: # fg: int, bg: int -192 # . prologue -193 55/push-ebp -194 89/<- %ebp 4/r32/esp -195 # . save registers -196 51/push-ecx -197 # var buf/ecx: (stream byte 32) -198 81 5/subop/subtract %esp 0x20/imm32 -199 68/push 0x20/imm32/size -200 68/push 0/imm32/read -201 68/push 0/imm32/write -202 89/<- %ecx 4/r32/esp -203 # construct directive in buf -204 # . set fg -205 (write %ecx Esc) -206 (write %ecx "[38;5;") -207 (print-int32-decimal %ecx *(ebp+8)) -208 (write %ecx "m") -209 # . set bg -210 (write %ecx Esc) -211 (write %ecx "[48;5;") -212 (print-int32-decimal %ecx *(ebp+0xc)) -213 (write %ecx "m") -214 # flush -215 (write-stream 2 %ecx) -216 $start-color:end: -217 # . reclaim locals -218 81 0/subop/add %esp 0x2c/imm32 -219 # . restore registers -220 59/pop-to-ecx -221 # . epilogue -222 89/<- %esp 5/r32/ebp -223 5d/pop-to-ebp -224 c3/return -225 -226 start-bold: -227 # . prologue -228 55/push-ebp -229 89/<- %ebp 4/r32/esp -230 # -231 (write 2 Esc) -232 (write 2 "[1m") -233 $start-bold:end: -234 # . epilogue -235 89/<- %esp 5/r32/ebp -236 5d/pop-to-ebp -237 c3/return -238 -239 start-underline: -240 # . prologue -241 55/push-ebp -242 89/<- %ebp 4/r32/esp -243 # -244 (write 2 Esc) -245 (write 2 "[4m") -246 $start-underline:end: -247 # . epilogue -248 89/<- %esp 5/r32/ebp -249 5d/pop-to-ebp -250 c3/return -251 -252 start-reverse-video: -253 # . prologue -254 55/push-ebp -255 89/<- %ebp 4/r32/esp -256 # -257 (write 2 Esc) -258 (write 2 "[7m") -259 $start-reverse-video:end: -260 # . epilogue -261 89/<- %esp 5/r32/ebp -262 5d/pop-to-ebp -263 c3/return -264 -265 # might require enabling blinking in your terminal program -266 start-blinking: -267 # . prologue -268 55/push-ebp -269 89/<- %ebp 4/r32/esp -270 # -271 (write 2 Esc) -272 (write 2 "[5m") -273 $start-blinking:end: -274 # . epilogue -275 89/<- %esp 5/r32/ebp -276 5d/pop-to-ebp -277 c3/return -278 -279 hide-cursor: -280 # . prologue -281 55/push-ebp -282 89/<- %ebp 4/r32/esp -283 # -284 (write 2 Esc) -285 (write 2 "[?25l") -286 $hide-cursor:end: -287 # . epilogue -288 89/<- %esp 5/r32/ebp -289 5d/pop-to-ebp -290 c3/return -291 -292 show-cursor: -293 # . prologue -294 55/push-ebp -295 89/<- %ebp 4/r32/esp -296 # -297 (write 2 Esc) -298 (write 2 "[?12l") -299 (write 2 Esc) -300 (write 2 "[?25h") -301 $show-cursor:end: -302 # . epilogue -303 89/<- %esp 5/r32/ebp -304 5d/pop-to-ebp -305 c3/return -306 -307 # This is a low-level detail; I don't think everything should be a file. -308 # -309 # Open "/dev/tty" if necessary and cache its file descriptor in Terminal-file-descriptor -310 # where later primitives can use it. -311 _maybe-open-terminal: -312 81 7/subop/compare *Terminal-file-descriptor -1/imm32 -313 75/jump-if-!= $_maybe-open-terminal:epilogue/disp8 -314 # . save registers -315 50/push-eax -316 51/push-ecx -317 53/push-ebx -318 # open("/dev/tty", O_RDWR) -319 bb/copy-to-ebx Terminal-filename/imm32 -320 b9/copy-to-ecx 2/imm32/O_RDWR -321 e8/call syscall_open/disp32 -322 89/<- *Terminal-file-descriptor 0/r32/eax -323 $_maybe-open-terminal:end: -324 # . restore registers -325 5b/pop-to-ebx -326 59/pop-to-ecx -327 58/pop-to-eax -328 $_maybe-open-terminal:epilogue: -329 c3/return -330 -331 == data -332 -333 Terminal-file-descriptor: # (addr int) -334 -1/imm32 + 42 52/push-edx + 43 53/push-ebx + 44 56/push-esi + 45 57/push-edi + 46 # + 47 (_maybe-open-terminal) + 48 # var window-size-info/esi: (addr winsize) + 49 # winsize is a type from the Linux kernel. We don't care how large it is. + 50 81 5/subop/subtract %esp 0x40/imm32 + 51 89/<- %esi 4/r32/esp + 52 # ioctl(*Terminal-file-descriptor, TIOCGWINSZ, window-size-info) + 53 89/<- %edx 6/r32/esi + 54 b9/copy-to-ecx 0x5413/imm32/TIOCGWINSZ + 55 8b/-> *Terminal-file-descriptor 3/r32/ebx + 56 e8/call syscall_ioctl/disp32 + 57 # some bitworking to extract 2 16-bit shorts + 58 8b/-> *esi 0/r32/eax + 59 81 4/subop/and %eax 0xffff/imm32 + 60 8b/-> *esi 1/r32/ecx + 61 c1/shift 5/subop/logical-right %ecx 0x10/imm8 + 62 $screen-size:end: + 63 # . reclaim locals + 64 81 0/subop/add %esp 0x40/imm32 + 65 # . restore registers + 66 5f/pop-to-edi + 67 5e/pop-to-esi + 68 5b/pop-to-ebx + 69 5a/pop-to-edx + 70 # . epilogue + 71 89/<- %esp 5/r32/ebp + 72 5d/pop-to-ebp + 73 c3/return + 74 + 75 clear-screen: + 76 # . prologue + 77 55/push-ebp + 78 89/<- %ebp 4/r32/esp + 79 # + 80 (write 2 Esc) + 81 (write 2 "[H") + 82 (write 2 Esc) + 83 (write 2 "[2J") + 84 $clear-screen:end: + 85 # . epilogue + 86 89/<- %esp 5/r32/ebp + 87 5d/pop-to-ebp + 88 c3/return + 89 + 90 # row and col count from the top-left as (1, 1) + 91 move-cursor: # row: int, column: int + 92 # . prologue + 93 55/push-ebp + 94 89/<- %ebp 4/r32/esp + 95 # . save registers + 96 51/push-ecx + 97 # var buf/ecx: (stream byte 32) + 98 81 5/subop/subtract %esp 0x20/imm32 + 99 68/push 0x20/imm32/size +100 68/push 0/imm32/read +101 68/push 0/imm32/write +102 89/<- %ecx 4/r32/esp +103 # construct directive in buf +104 (write %ecx Esc) +105 (write %ecx "[") +106 (print-int32-decimal %ecx *(ebp+8)) +107 (write %ecx ";") +108 (print-int32-decimal %ecx *(ebp+0xc)) +109 (write %ecx "H") +110 # flush +111 (write-stream 2 %ecx) +112 $move-cursor:end: +113 # . reclaim locals +114 81 0/subop/add %esp 0x2c/imm32 +115 # . restore registers +116 59/pop-to-ecx +117 # . epilogue +118 89/<- %esp 5/r32/ebp +119 5d/pop-to-ebp +120 c3/return +121 +122 print-string: # s: (addr array byte) +123 # . prologue +124 55/push-ebp +125 89/<- %ebp 4/r32/esp +126 # +127 (write 2 *(ebp+8)) +128 $print-string:end: +129 # . epilogue +130 89/<- %esp 5/r32/ebp +131 5d/pop-to-ebp +132 c3/return +133 +134 # just because Mu has no support for global variables yet +135 print-byte: # c: byte +136 # . prologue +137 55/push-ebp +138 89/<- %ebp 4/r32/esp +139 # . save registers +140 51/push-ecx +141 # var s/ecx: (addr array byte) +142 ff 6/subop/push *(ebp+8) +143 68/push 4/imm32/size +144 89/<- %ecx 4/r32/esp +145 (write 2 %ecx) +146 $print-byte:end: +147 # . reclaim locals +148 81 0/subop/add %esp 8/imm32 +149 # . restore registers +150 59/pop-to-ecx +151 # . epilogue +152 89/<- %esp 5/r32/ebp +153 5d/pop-to-ebp +154 c3/return +155 +156 # just because Mu has no support for global variables yet +157 print-int32-to-screen: # n: int +158 # . prologue +159 55/push-ebp +160 89/<- %ebp 4/r32/esp +161 # +162 (print-int32-buffered Stdout *(ebp+8)) +163 (flush Stdout) +164 $print-int32-to-screen:end: +165 # . epilogue +166 89/<- %esp 5/r32/ebp +167 5d/pop-to-ebp +168 c3/return +169 +170 reset-formatting: +171 # . prologue +172 55/push-ebp +173 89/<- %ebp 4/r32/esp +174 # +175 (write 2 Esc) +176 (write 2 "(B") +177 (write 2 Esc) +178 (write 2 "[m") +179 $reset-formatting:end: +180 # . epilogue +181 89/<- %esp 5/r32/ebp +182 5d/pop-to-ebp +183 c3/return +184 +185 start-color: # fg: int, bg: int +186 # . prologue +187 55/push-ebp +188 89/<- %ebp 4/r32/esp +189 # . save registers +190 51/push-ecx +191 # var buf/ecx: (stream byte 32) +192 81 5/subop/subtract %esp 0x20/imm32 +193 68/push 0x20/imm32/size +194 68/push 0/imm32/read +195 68/push 0/imm32/write +196 89/<- %ecx 4/r32/esp +197 # construct directive in buf +198 # . set fg +199 (write %ecx Esc) +200 (write %ecx "[38;5;") +201 (print-int32-decimal %ecx *(ebp+8)) +202 (write %ecx "m") +203 # . set bg +204 (write %ecx Esc) +205 (write %ecx "[48;5;") +206 (print-int32-decimal %ecx *(ebp+0xc)) +207 (write %ecx "m") +208 # flush +209 (write-stream 2 %ecx) +210 $start-color:end: +211 # . reclaim locals +212 81 0/subop/add %esp 0x2c/imm32 +213 # . restore registers +214 59/pop-to-ecx +215 # . epilogue +216 89/<- %esp 5/r32/ebp +217 5d/pop-to-ebp +218 c3/return +219 +220 start-bold: +221 # . prologue +222 55/push-ebp +223 89/<- %ebp 4/r32/esp +224 # +225 (write 2 Esc) +226 (write 2 "[1m") +227 $start-bold:end: +228 # . epilogue +229 89/<- %esp 5/r32/ebp +230 5d/pop-to-ebp +231 c3/return +232 +233 start-underline: +234 # . prologue +235 55/push-ebp +236 89/<- %ebp 4/r32/esp +237 # +238 (write 2 Esc) +239 (write 2 "[4m") +240 $start-underline:end: +241 # . epilogue +242 89/<- %esp 5/r32/ebp +243 5d/pop-to-ebp +244 c3/return +245 +246 start-reverse-video: +247 # . prologue +248 55/push-ebp +249 89/<- %ebp 4/r32/esp +250 # +251 (write 2 Esc) +252 (write 2 "[7m") +253 $start-reverse-video:end: +254 # . epilogue +255 89/<- %esp 5/r32/ebp +256 5d/pop-to-ebp +257 c3/return +258 +259 # might require enabling blinking in your terminal program +260 start-blinking: +261 # . prologue +262 55/push-ebp +263 89/<- %ebp 4/r32/esp +264 # +265 (write 2 Esc) +266 (write 2 "[5m") +267 $start-blinking:end: +268 # . epilogue +269 89/<- %esp 5/r32/ebp +270 5d/pop-to-ebp +271 c3/return +272 +273 hide-cursor: +274 # . prologue +275 55/push-ebp +276 89/<- %ebp 4/r32/esp +277 # +278 (write 2 Esc) +279 (write 2 "[?25l") +280 $hide-cursor:end: +281 # . epilogue +282 89/<- %esp 5/r32/ebp +283 5d/pop-to-ebp +284 c3/return +285 +286 show-cursor: +287 # . prologue +288 55/push-ebp +289 89/<- %ebp 4/r32/esp +290 # +291 (write 2 Esc) +292 (write 2 "[?12l") +293 (write 2 Esc) +294 (write 2 "[?25h") +295 $show-cursor:end: +296 # . epilogue +297 89/<- %esp 5/r32/ebp +298 5d/pop-to-ebp +299 c3/return +300 +301 # This is a low-level detail; I don't think everything should be a file. +302 # +303 # Open "/dev/tty" if necessary and cache its file descriptor in Terminal-file-descriptor +304 # where later primitives can use it. +305 _maybe-open-terminal: +306 81 7/subop/compare *Terminal-file-descriptor -1/imm32 +307 75/jump-if-!= $_maybe-open-terminal:epilogue/disp8 +308 # . save registers +309 50/push-eax +310 51/push-ecx +311 53/push-ebx +312 # open("/dev/tty", O_RDWR) +313 bb/copy-to-ebx Terminal-filename/imm32 +314 b9/copy-to-ecx 2/imm32/O_RDWR +315 e8/call syscall_open/disp32 +316 89/<- *Terminal-file-descriptor 0/r32/eax +317 $_maybe-open-terminal:end: +318 # . restore registers +319 5b/pop-to-ebx +320 59/pop-to-ecx +321 58/pop-to-eax +322 $_maybe-open-terminal:epilogue: +323 c3/return +324 +325 == data +326 +327 Terminal-file-descriptor: # (addr int) +328 -1/imm32 +329 +330 Esc: # (addr array byte) +331 # size +332 1/imm32 +333 # data +334 0x1b 335 -336 Esc: # (addr array byte) -337 # size -338 1/imm32 -339 # data -340 0x1b -341 -342 Terminal-filename: # (addr kernel-string) -343 # "/dev/null" -344 2f/slash 64/d 65/e 76/v 2f/slash 74/t 74/t 79/y 0/nul +336 Terminal-filename: # (addr kernel-string) +337 # "/dev/null" +338 2f/slash 64/d 65/e 76/v 2f/slash 74/t 74/t 79/y 0/nul diff --git a/html/apps/browse.mu.html b/html/apps/browse.mu.html new file mode 100644 index 00000000..cc49d082 --- /dev/null +++ b/html/apps/browse.mu.html @@ -0,0 +1,184 @@ + + + + +Mu - apps/browse.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/master/apps/browse.mu +
+  1 # render text with word-wrap
+  2 
+  3 fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
+  4   var filename/eax: (addr array byte) <- first-arg args
+  5   var file/esi: (addr buffered-file) <- load-file filename
+  6   enable-screen-grid-mode
+  7   var nrows/eax: int <- copy 0
+  8   var ncols/ecx: int <- copy 0
+  9   nrows, ncols <- screen-size
+ 10   enable-keyboard-immediate-mode
+ 11   {
+ 12     render file, nrows, ncols
+ 13     var key/eax: byte <- read-key
+ 14     compare key, 0x71  # 'q'
+ 15     loop-if-!=
+ 16   }
+ 17   enable-keyboard-type-mode
+ 18   enable-screen-type-mode
+ 19   exit-status <- copy 0
+ 20 }
+ 21 
+ 22 # decide how to lay out pages on screen
+ 23 fn render in: (addr buffered-file), nrows: int, ncols: int {
+ 24   # Fit n pages on screen on separate columns, each wide enough to read
+ 25   # comfortably.
+ 26   # Pages are separated horizontally by a 'page margin'. Among other reasons,
+ 27   # this allows the odd line to bleed out on the right if necessary.
+ 28   #
+ 29   # hardcoded parameters:
+ 30   #   top-margin
+ 31   #   page-margin
+ 32   #   text-width
+ 33   var npages/eax: int <- num-pages ncols, 0x40, 5  # text-width, page-margin
+ 34   var toprow/eax: int <- copy 2  # top-margin
+ 35   var botrow/ecx: int <- copy nrows
+ 36   var leftcol/edx: int <- copy 5  # page-margin
+ 37   var rightcol/ebx: int <- copy leftcol
+ 38   rightcol <- add 0x40  # text-width = 64 characters
+ 39   {
+ 40     compare rightcol, ncols
+ 41     break-if->=
+ 42     render-page in, toprow, leftcol, botrow, rightcol
+ 43     leftcol <- copy rightcol
+ 44     leftcol <- add 5  # page-margin
+ 45     rightcol <- copy leftcol
+ 46     rightcol <- add 0x40  # text-width
+ 47     loop
+ 48   }
+ 49 }
+ 50 
+ 51 fn num-pages ncols: int, text-width: int, page-margin: int -> result/eax: int {
+ 52   result <- copy 3
+ 53 }
+ 54 
+ 55 fn render-page in: (addr buffered-file), toprow: int, leftcol: int, botrow: int, rightcol: int {
+ 56   clear toprow, leftcol, botrow, rightcol
+ 57   # render screen rows
+ 58   var row/ecx: int <- copy toprow
+ 59 $line-loop:  {
+ 60     compare row, botrow
+ 61     break-if->=
+ 62     var col/edx: int <- copy leftcol
+ 63     move-cursor row, col
+ 64     {
+ 65       compare col, rightcol
+ 66       break-if->=
+ 67       var c/eax: byte <- read-byte-buffered in
+ 68       compare c, 0xffffffff  # EOF marker
+ 69       break-if-= $line-loop
+ 70       compare c, 0xa  # newline
+ 71       break-if-=  # no need to print newlines
+ 72       print-byte c
+ 73       col <- increment
+ 74       loop
+ 75     }
+ 76     row <- increment
+ 77     loop
+ 78   }
+ 79 }
+ 80 
+ 81 fn clear toprow: int, leftcol: int, botrow: int, rightcol: int {
+ 82   var row/ecx: int <- copy toprow
+ 83   {
+ 84     compare row, botrow
+ 85     break-if->=
+ 86     var col/edx: int <- copy leftcol
+ 87     move-cursor row, col
+ 88     {
+ 89       compare col, rightcol
+ 90       break-if->=
+ 91       print-string " "
+ 92       col <- increment
+ 93       loop
+ 94     }
+ 95     row <- increment
+ 96     loop
+ 97   }
+ 98 }
+ 99 
+100 fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr array byte) {
+101   var args/eax: (addr array (addr array byte)) <- copy args-on-stack
+102   var result/eax: (addr addr array byte) <- index args, 1
+103   out <- copy *result
+104 }
+105 
+106 fn load-file filename: (addr array byte) -> out/esi: (addr buffered-file) {
+107   var result: (handle buffered-file)
+108   {
+109     var tmp1/eax: (addr handle buffered-file) <- address result
+110     open filename, 0, tmp1
+111   }
+112   var tmp2/eax: (addr buffered-file) <- lookup result
+113   out <- copy tmp2
+114 }
+115 
+116 fn dump in: (addr buffered-file) {
+117   var c/eax: byte <- read-byte-buffered in
+118   compare c, 0xffffffff  # EOF marker
+119   break-if-=
+120   print-byte c
+121   loop
+122 }
+
+ + + diff --git a/html/apps/print-file.mu.html b/html/apps/print-file.mu.html index b5fe387e..80a2d04a 100644 --- a/html/apps/print-file.mu.html +++ b/html/apps/print-file.mu.html @@ -72,7 +72,7 @@ if ('onhashchange' in window) { 14 compare n, 1 15 { 16 break-if-> -17 print-string "usage: cat <filename>\n" +17 print-string "usage: cat <filename>\n" 18 break $main-body 19 } 20 { @@ -87,16 +87,15 @@ if ('onhashchange' in window) { 29 var in-addr/ecx: (addr buffered-file) <- copy _in-addr 30 { 31 var c/eax: byte <- read-byte-buffered in-addr -32 compare c, 0xffffffff +32 compare c, 0xffffffff # EOF marker 33 break-if-= -34 print-byte c +34 print-byte c 35 loop 36 } 37 } 38 } -39 flush-stdout -40 exit-status <- copy 0 -41 } +39 exit-status <- copy 0 +40 } -- cgit 1.4.1-2-gfad0