diff --git a/html/052kernel-string-equal.subx.html b/html/052kernel-string-equal.subx.html index c19d9e75..8a2dc15e 100644 --- a/html/052kernel-string-equal.subx.html +++ b/html/052kernel-string-equal.subx.html @@ -70,8 +70,8 @@ if ('onhashchange' in window) { 8 # null-terminated 'kernel string' with a length-prefixed 'SubX string'. 9 # 10 # To run (from the subx directory): - 11 # $ ./subx translate 05[0-2]*.subx -o /tmp/tmp52 - 12 # $ ./subx run /tmp/tmp52 # runs a series of tests + 11 # $ ./bootstrap translate 05[0-2]*.subx -o /tmp/tmp52 + 12 # $ ./bootstrap run /tmp/tmp52 # runs a series of tests 13 # ...... # all tests pass 14 # 15 # (We can't yet run the tests when given a "test" commandline argument, diff --git a/html/apps/ex1.mu.html b/html/apps/ex1.mu.html new file mode 100644 index 00000000..a404b378 --- /dev/null +++ b/html/apps/ex1.mu.html @@ -0,0 +1,73 @@ + + +
+ ++ 1 # First example: return the answer to the Ultimate Question of Life, the + 2 # Universe, and Everything. + 3 # + 4 # To run: + 5 # $ ./translate_mu apps/ex1.mu + 6 # $ ./a.elf + 7 # Expected result: + 8 # $ echo $? + 9 # 42 +10 +11 fn main -> result/ebx: int { +12 result <- copy 0x2a # Mu requires hexadecimal +13 } ++ + + diff --git a/html/apps/ex1.subx.html b/html/apps/ex1.subx.html index c4105769..4cc9e90f 100644 --- a/html/apps/ex1.subx.html +++ b/html/apps/ex1.subx.html @@ -2,7 +2,7 @@ -
1 # First program: same as https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html 2 # Just return 42. @@ -67,7 +67,7 @@ if ('onhashchange' in window) { 12 13 Entry: 14 # exit(42) -15 bb/copy-to-ebx 2a/imm32 # 42 in hex +15 bb/copy-to-ebx 0x2a/imm32 # 42 in hex 16 e8/call syscall_exit/disp32 17 18 # . . vim:nowrap:textwidth=0 diff --git a/html/apps/ex10.subx.html b/html/apps/ex10.subx.html index bcf0e466..2671b311 100644 --- a/html/apps/ex10.subx.html +++ b/html/apps/ex10.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex10.subx +Mu - apps/ex10.subx @@ -55,7 +55,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex10.subx +https://github.com/akkartik/mu/blob/master/apps/ex10.subx1 # String comparison: return 1 iff the two args passed in at the commandline are equal. 2 # diff --git a/html/apps/ex11.subx.html b/html/apps/ex11.subx.html index 47c0b289..28fa18f0 100644 --- a/html/apps/ex11.subx.html +++ b/html/apps/ex11.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex11.subx +Mu - apps/ex11.subx @@ -58,7 +58,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex11.subx +https://github.com/akkartik/mu/blob/master/apps/ex11.subx1 # Null-terminated vs length-prefixed ascii strings. 2 # @@ -181,9 +181,9 @@ if ('onhashchange' in window) { 119 # eax = kernel-string-equal?(Null-kernel-string, "") 120 # . . push args 121 68/push ""/imm32 -122 68/push Null-kernel-string/imm32 +122 68/push Null-kernel-string/imm32 123 # . . call -124 e8/call kernel-string-equal?/disp32 +124 e8/call kernel-string-equal?/disp32 125 # . . discard args 126 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 127 # check-ints-equal(eax, 1, msg) @@ -192,7 +192,7 @@ if ('onhashchange' in window) { 130 68/push 1/imm32/true 131 50/push-eax 132 # . . call -133 e8/call check-ints-equal/disp32 +133 e8/call check-ints-equal/disp32 134 # . . discard args 135 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 136 c3/return @@ -201,9 +201,9 @@ if ('onhashchange' in window) { 139 # eax = kernel-string-equal?(Null-kernel-string, "Abc") 140 # . . push args 141 68/push "Abc"/imm32 -142 68/push Null-kernel-string/imm32 +142 68/push Null-kernel-string/imm32 143 # . . call -144 e8/call kernel-string-equal?/disp32 +144 e8/call kernel-string-equal?/disp32 145 # . . discard args 146 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 147 # check-ints-equal(eax, 0, msg) @@ -212,7 +212,7 @@ if ('onhashchange' in window) { 150 68/push 0/imm32/false 151 50/push-eax 152 # . . call -153 e8/call check-ints-equal/disp32 +153 e8/call check-ints-equal/disp32 154 # . . discard args 155 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 156 c3/return @@ -221,9 +221,9 @@ if ('onhashchange' in window) { 159 # eax = kernel-string-equal?(_test-Abc-kernel-string, "Abc") 160 # . . push args 161 68/push "Abc"/imm32 -162 68/push _test-Abc-kernel-string/imm32 +162 68/push _test-Abc-kernel-string/imm32 163 # . . call -164 e8/call kernel-string-equal?/disp32 +164 e8/call kernel-string-equal?/disp32 165 # . . discard args 166 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 167 # check-ints-equal(eax, 1, msg) @@ -232,7 +232,7 @@ if ('onhashchange' in window) { 170 68/push 1/imm32/true 171 50/push-eax 172 # . . call -173 e8/call check-ints-equal/disp32 +173 e8/call check-ints-equal/disp32 174 # . . discard args 175 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 176 c3/return @@ -241,9 +241,9 @@ if ('onhashchange' in window) { 179 # eax = kernel-string-equal?(_test-Abc-kernel-string, "Adc") 180 # . . push args 181 68/push "Adc"/imm32 -182 68/push _test-Abc-kernel-string/imm32 +182 68/push _test-Abc-kernel-string/imm32 183 # . . call -184 e8/call kernel-string-equal?/disp32 +184 e8/call kernel-string-equal?/disp32 185 # . . discard args 186 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 187 # check-ints-equal(eax, 0, msg) @@ -252,7 +252,7 @@ if ('onhashchange' in window) { 190 68/push 0/imm32/false 191 50/push-eax 192 # . . call -193 e8/call check-ints-equal/disp32 +193 e8/call check-ints-equal/disp32 194 # . . discard args 195 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 196 c3/return @@ -261,9 +261,9 @@ if ('onhashchange' in window) { 199 # eax = kernel-string-equal?(_test-Abc-kernel-string, "") 200 # . . push args 201 68/push ""/imm32 -202 68/push _test-Abc-kernel-string/imm32 +202 68/push _test-Abc-kernel-string/imm32 203 # . . call -204 e8/call kernel-string-equal?/disp32 +204 e8/call kernel-string-equal?/disp32 205 # . . discard args 206 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 207 # check-ints-equal(eax, 0, msg) @@ -272,7 +272,7 @@ if ('onhashchange' in window) { 210 68/push 0/imm32/false 211 50/push-eax 212 # . . call -213 e8/call check-ints-equal/disp32 +213 e8/call check-ints-equal/disp32 214 # . . discard args 215 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 216 c3/return @@ -281,9 +281,9 @@ if ('onhashchange' in window) { 219 # eax = kernel-string-equal?(_test-Abc-kernel-string, "Ab") 220 # . . push args 221 68/push "Ab"/imm32 -222 68/push _test-Abc-kernel-string/imm32 +222 68/push _test-Abc-kernel-string/imm32 223 # . . call -224 e8/call kernel-string-equal?/disp32 +224 e8/call kernel-string-equal?/disp32 225 # . . discard args 226 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 227 # check-ints-equal(eax, 0, msg) @@ -292,7 +292,7 @@ if ('onhashchange' in window) { 230 68/push 0/imm32/false 231 50/push-eax 232 # . . call -233 e8/call check-ints-equal/disp32 +233 e8/call check-ints-equal/disp32 234 # . . discard args 235 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 236 c3/return @@ -301,9 +301,9 @@ if ('onhashchange' in window) { 239 # eax = kernel-string-equal?(_test-Abc-kernel-string, "Abcd") 240 # . . push args 241 68/push "Abcd"/imm32 -242 68/push _test-Abc-kernel-string/imm32 +242 68/push _test-Abc-kernel-string/imm32 243 # . . call -244 e8/call kernel-string-equal?/disp32 +244 e8/call kernel-string-equal?/disp32 245 # . . discard args 246 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp 247 # check-ints-equal(eax, 0, msg) @@ -312,7 +312,7 @@ if ('onhashchange' in window) { 250 68/push 0/imm32/false 251 50/push-eax 252 # . . call -253 e8/call check-ints-equal/disp32 +253 e8/call check-ints-equal/disp32 254 # . . discard args 255 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp 256 c3/return @@ -355,7 +355,7 @@ if ('onhashchange' in window) { 293 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32 # add to esp 294 # print newline 295 # . . push args -296 68/push Newline/imm32 +296 68/push Newline/imm32 297 # . . call 298 e8/call write-stderr/disp32 299 # . . discard args diff --git a/html/apps/ex12.subx.html b/html/apps/ex12.subx.html index a6b2dc64..221bec80 100644 --- a/html/apps/ex12.subx.html +++ b/html/apps/ex12.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex12.subx +Mu - apps/ex12.subx @@ -53,7 +53,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex12.subx +https://github.com/akkartik/mu/blob/master/apps/ex12.subx1 # Example showing mmap syscall. 2 # Create a new segment using mmap, save the address, write to it. diff --git a/html/apps/ex2.mu.html b/html/apps/ex2.mu.html new file mode 100644 index 00000000..94429de0 --- /dev/null +++ b/html/apps/ex2.mu.html @@ -0,0 +1,78 @@ + + + + +Mu - apps/ex2.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/master/apps/ex2.mu ++ 1 # Add two numbers, and return the result in the exit code. + 2 # + 3 # To run: + 4 # $ ./translate_mu apps/ex2.mu + 5 # $ ./a.elf + 6 # Expected result: + 7 # $ echo $? + 8 # 7 + 9 +10 fn main -> result/ebx: int { +11 result <- do-add 3 4 +12 } +13 +14 fn do-add a: int, b: int -> result/ebx: int { +15 result <- copy a +16 result <- add b +17 } ++ + + diff --git a/html/apps/ex2.subx.html b/html/apps/ex2.subx.html index c67315e9..f1e4abe9 100644 --- a/html/apps/ex2.subx.html +++ b/html/apps/ex2.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex2.subx +Mu - apps/ex2.subx @@ -51,7 +51,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex2.subx +https://github.com/akkartik/mu/blob/master/apps/ex2.subx1 # Add 1 and 1, and return the result in the exit code. 2 # diff --git a/html/apps/ex3.subx.html b/html/apps/ex3.subx.html index 7c3da099..e5eece81 100644 --- a/html/apps/ex3.subx.html +++ b/html/apps/ex3.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex3.subx +Mu - apps/ex3.subx @@ -54,7 +54,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex3.subx +https://github.com/akkartik/mu/blob/master/apps/ex3.subx1 # Add the first 10 numbers, and return the result in the exit code. 2 # diff --git a/html/apps/ex4.subx.html b/html/apps/ex4.subx.html index 43f5c705..b1e1019b 100644 --- a/html/apps/ex4.subx.html +++ b/html/apps/ex4.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex4.subx +Mu - apps/ex4.subx @@ -52,7 +52,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex4.subx +https://github.com/akkartik/mu/blob/master/apps/ex4.subx1 # Read a character from stdin, save it to a global, write it to stdout. 2 # diff --git a/html/apps/ex5.subx.html b/html/apps/ex5.subx.html index f5112fa7..26c5700b 100644 --- a/html/apps/ex5.subx.html +++ b/html/apps/ex5.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex5.subx +Mu - apps/ex5.subx @@ -53,7 +53,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex5.subx +https://github.com/akkartik/mu/blob/master/apps/ex5.subx1 # Read a character from stdin, save it to a local on the stack, write it to stdout. 2 # diff --git a/html/apps/ex6.subx.html b/html/apps/ex6.subx.html index c8bbdd21..e8f7dbe4 100644 --- a/html/apps/ex6.subx.html +++ b/html/apps/ex6.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex6.subx +Mu - apps/ex6.subx @@ -53,7 +53,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex6.subx +https://github.com/akkartik/mu/blob/master/apps/ex6.subx1 # Print out a (global variable) string to stdout. 2 # diff --git a/html/apps/ex7.subx.html b/html/apps/ex7.subx.html index 762bf7ec..617c44c2 100644 --- a/html/apps/ex7.subx.html +++ b/html/apps/ex7.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex7.subx +Mu - apps/ex7.subx @@ -53,7 +53,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex7.subx +https://github.com/akkartik/mu/blob/master/apps/ex7.subx1 # Example showing file syscalls. 2 # diff --git a/html/apps/ex8.subx.html b/html/apps/ex8.subx.html index 1f57fcdf..ab67bb1f 100644 --- a/html/apps/ex8.subx.html +++ b/html/apps/ex8.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex8.subx +Mu - apps/ex8.subx @@ -55,7 +55,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex8.subx +https://github.com/akkartik/mu/blob/master/apps/ex8.subx1 # Example reading commandline arguments: compute length of first arg. 2 # diff --git a/html/apps/ex9.subx.html b/html/apps/ex9.subx.html index fbf7b76c..bddb6ff0 100644 --- a/html/apps/ex9.subx.html +++ b/html/apps/ex9.subx.html @@ -2,7 +2,7 @@ -Mu - examples/ex9.subx +Mu - apps/ex9.subx @@ -54,7 +54,7 @@ if ('onhashchange' in window) { -https://github.com/akkartik/mu/blob/master/examples/ex9.subx +https://github.com/akkartik/mu/blob/master/apps/ex9.subx1 # Example showing arg order on the stack. 2 # diff --git a/tools/update_html b/tools/update_html index 478d5d6c..7efddfe7 100755 --- a/tools/update_html +++ b/tools/update_html @@ -45,15 +45,6 @@ do process $f done -for f in examples/*.subx -do - test $# -gt 0 && test $1 != $f && continue - ( cd examples - ctags -x `basename $f` > /tmp/tags - ) - process $f -done - ctags -x *.subx > /tmp/tags for f in *.subx do @@ -70,4 +61,13 @@ do process $f done +for f in apps/*.mu +do + test $# -gt 0 && test $1 != $f && continue + ( cd apps + ctags -x ../*.subx `basename $f` > /tmp/tags + ) + process $f +done + rm /tmp/tags