From 0e3d05fafc8995793b8983e9c2d4a27b406fd70e Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Thu, 10 Oct 2019 01:00:32 +0500 Subject: [PATCH] make stage0 monitor 4 bytes smaller by using FALSE to put zero in R1 --- bootstrapping Steps.org | 2 +- stage0/stage0_monitor.hex0 | 34 +++++++++++++++++----------------- stage0/stage0_monitor.s | 4 ++-- test/SHA256SUMS | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bootstrapping Steps.org b/bootstrapping Steps.org index 958f8c5..94c8dc1 100644 --- a/bootstrapping Steps.org +++ b/bootstrapping Steps.org @@ -37,7 +37,7 @@ gcc Linux\ Bootstrap/hex.c -o bin/hex Then we can use it to make our bootstrap binary: ./bin/hex < stage0/stage0_monitor.hex0 > roms/stage0_monitor -Which should have the sha256sum of 23929c57f41414f57583457d0500f22b5b1c80f39c79522e23c8b13e5afb191d +Which should have the sha256sum of 792e2be913921dd55a28f55dcf2e6b1523d34fdbccc27c38f77e74c99ef97a4b * Step 2 create a hex assembler Now that we have a Hex monitor, we are now capable of either creating a text file (no ability to correct mistakes along the way) or any arbitrary hex program we want. diff --git a/stage0/stage0_monitor.hex0 b/stage0/stage0_monitor.hex0 index 0a7bb65..98e0929 100644 --- a/stage0/stage0_monitor.hex0 +++ b/stage0/stage0_monitor.hex0 @@ -29,7 +29,7 @@ E0002D201101 # LOADUI R0 0x1101 42100001 # FOPEN_WRITE # :loop 24 -E0002D210000 # LOADUI R1 0 ; Read from tty +0D000021 # FALSE R1 ; Read from tty 42100100 # FGETC ; Read a Char E000A030000d # CMPSKIPI.NE R0 13 ; Replace all CR E0002D20000a # LOADUI R0 10 ; WIth LF @@ -38,10 +38,10 @@ E0002D20000a # LOADUI R0 10 ; WIth LF # ;; Check for Ctrl-D E000A0300004 # CMPSKIPI.NE R0 4 -3C000112 # JUMP @finish +3C000110 # JUMP @finish # ;; Check for EOF -E0002CC0010c # JUMP.NP R0 @finish +E0002CC0010a # JUMP.NP R0 @finish # ;; Write out unprocessed byte E0002D211101 # LOADUI R1 0x1101 ; Write to TAPE_02 @@ -51,7 +51,7 @@ E0002D211101 # LOADUI R1 0x1101 ; Write to TAPE_02 E0002D0D003e # CALLI R13 @hex ; Convert it # ;; Get another byte if nonhex -E0002CC0ffc0 # JUMP.NP R0 @loop ; Don't use nonhex chars +E0002CC0ffc2 # JUMP.NP R0 @loop ; Don't use nonhex chars # ;; Deal with the case of second nybble E0002C9B000e # JUMP.Z R11 @second_nybble ; Jump if toggled @@ -59,10 +59,10 @@ E0002C9B000e # JUMP.Z R11 @second_nybble ; Jump if toggled # ;; Process first byte of pair E100B0F0000f # ANDI R15 R0 0x0F ; Store First nibble 0D00002B # FALSE R11 ; Flip the toggle -3C00ffac # JUMP @loop +3C00ffae # JUMP @loop # ;; Combined second nybble in pair with first -# :second_nybble 78 +# :second_nybble 76 E0002D5F0004 # SL0I R15 4 ; Shift our first nibble E100B000000f # ANDI R0 R0 0x0F ; Mask out top 0500000F # ADD R0 R0 R15 ; Combine nibbles @@ -71,9 +71,9 @@ E100B000000f # ANDI R0 R0 0x0F ; Mask out top E0002D1B0001 # LOADI R11 1 ; Flip the toggle E0002D211100 # LOADUI R1 0x1100 ; Write the combined byte 42100200 # FPUTC ; To TAPE_01 -3C00ff88 # JUMP @loop ; Try to get more bytes +3C00ff8a # JUMP @loop ; Try to get more bytes -# :hex 9c +# :hex 9a # ;; Deal with line comments starting with # E1001FE00023 # CMPUI R14 R0 35 E0002C5E007e # JUMP.E R14 @ascii_comment @@ -109,24 +109,24 @@ E0002C7E000e # JUMP.LE R14 @ascii_low # ;; Ignore the rest 3C00001e # JUMP @ascii_other -# :ascii_num 100 +# :ascii_num FD E10011000030 # SUBUI R0 R0 48 0D01001D # RET R13 -# :ascii_low 10a +# :ascii_low 108 E10011000057 # SUBUI R0 R0 87 0D01001D # RET R13 -# :ascii_high 114 +# :ascii_high 112 E10011000037 # SUBUI R0 R0 55 0D01001D # RET R13 -# :ascii_other 11e +# :ascii_other 11c 0D000030 # TRUE R0 0D01001D # RET R13 -# :ascii_comment 126 -E0002D210000 # LOADUI R1 0 ; Read from tty +# :ascii_comment 124 +0D000021 # FALSE R1 ; Read from tty 42100100 # FGETC ; Read another char E000A030000d # CMPSKIPI.NE R0 13 ; Replace all CR E0002D20000a # LOADUI R0 10 ; WIth LF @@ -134,10 +134,10 @@ E0002D20000a # LOADUI R0 10 ; WIth LF E1001FE0000a # CMPUI R14 R0 10 ; Stop at the end of line E0002D211101 # LOADUI R1 0x1101 ; Write to TAPE_02 42100200 # FPUTC ; The char we just read -E0002C6Effd0 # JUMP.NE R14 @ascii_comment ; Otherwise keep looping -3C00ffc4 # JUMP @ascii_other +E0002C6Effd2 # JUMP.NE R14 @ascii_comment ; Otherwise keep looping +3C00ffc6 # JUMP @ascii_other -# :finish 15a +# :finish 156 E0002D201100 # LOADUI R0 0x1100 ; Close TAPE_01 42100002 # FCLOSE E0002D201101 # LOADUI R0 0x1101 ; Close TAPE_02 diff --git a/stage0/stage0_monitor.s b/stage0/stage0_monitor.s index 61b5cc0..746f6ca 100644 --- a/stage0/stage0_monitor.s +++ b/stage0/stage0_monitor.s @@ -29,7 +29,7 @@ FOPEN_WRITE :loop - LOADUI R1 0 ; Read from tty + FALSE R1 ; Read from tty FGETC ; Read a Char CMPSKIPI.NE R0 13 ; Replace all CR @@ -115,7 +115,7 @@ TRUE R0 RET R13 :ascii_comment - LOADUI R1 0 ; Read from tty + FALSE R1 ; Read from tty FGETC ; Read another char CMPSKIPI.NE R0 13 ; Replace all CR LOADUI R0 10 ; WIth LF diff --git a/test/SHA256SUMS b/test/SHA256SUMS index 34cba4d..5741dbd 100644 --- a/test/SHA256SUMS +++ b/test/SHA256SUMS @@ -5,7 +5,7 @@ f4bbf9e9c4828170d0c153ac265382dc705643f95efd2a029243326d426be5a4 roms/forth 2b80849180d5fb3757bcca2471b6337808e5b5ca80b18d93fa82ddef0435b84b roms/lisp 3020b194ead31ae19ba66fc35ed95465514373f6005896350d1608c9efabbdca roms/M0 059d38e34275029f2de5f600f08fe01bd13cd173f7da58e3fbec7114074beff2 roms/SET -23929c57f41414f57583457d0500f22b5b1c80f39c79522e23c8b13e5afb191d roms/stage0_monitor +792e2be913921dd55a28f55dcf2e6b1523d34fdbccc27c38f77e74c99ef97a4b roms/stage0_monitor 13b45134a88c1c6db349cb40f82269cee9edfce71ac644dc0e137bad053bf5ce roms/stage1_assembler-0 156f555fce5b02f52445652b1ed0b443295706cdfbe23c5a021bd4efc77179bb roms/stage1_assembler-1 2c02c50958f489a660a4915d2a9e207a0c61f411d42628bdaf4dcf6bf7149a9d roms/stage1_assembler-2