Shrink stage1_assembler-1 further

This commit is contained in:
Jeremiah Orians 2017-12-23 17:53:31 -05:00
parent cb2bc1309f
commit c81c2567ab
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
4 changed files with 24 additions and 42 deletions

View File

@ -93,7 +93,7 @@ So we are going to limit ourselves to single character labels and pointers (:a a
To build our improved hex assembler:
./bin/vm --rom roms/stage1_assembler-0 --tape_01 stage1/stage1_assembler-1.hex0 --tape_02 roms/stage1_assembler-1
roms/stage1_assembler-1 should have the sha256sum of e59338381ca3ab01a14fa0fc85d0fa1c6e4d59a06ac2d9d75668d878ab469769
roms/stage1_assembler-1 should have the sha256sum of b6aabcc3418a0a28f4ed32ace43b20103d9d21dffae03e7936cb14fa0e044013
* Step 4 get even long label support
Now that we have labels and pointers, I want the ability to have labels like :main_function and :stack_start and be able to reference the absolute address of things in my code like $stack_start and complex objects that have 32bit pointers like &foo_bar.

View File

@ -15,7 +15,7 @@
## along with stage0. If not, see <http://www.gnu.org/licenses/>.
#:start 0
2D2B019C # LOADUI R11 $table ; Where we are putting our address pointers
2D2B0200 # LOADUI R11 0x200 ; Where we are putting our address pointers
0D00003C # TRUE R12 ; Our toggle
0D00002D # FALSE R13 ; Our PC counter
2D2E0040 # LOADUI R14 $getLables_2 ; our first iterator
@ -92,7 +92,8 @@ A0300040 # CMPSKIPI.NE R0 64 ; If the Char is @ the next char is the pointer to
#:loop 88
42100100 # FGETC ; Read a Char
2CC000FC # JUMP.NP R0 @finish ; Check for EOF
# ;; Check for EOF
2CC000E8 # JUMP.NP R0 @finish
# ;; Check for Label
A030003A # CMPSKIPI.NE R0 58 ; Make sure we jump over the label
@ -162,61 +163,49 @@ B00300FF # ANDI R0 R3 0xFF ; Preserve bottom half for later
#:hex 118
# ;; Deal with line comments starting with #
A0300023 # CMPSKIPI.NE R0 35
3C000058 # JUMP @ascii_comment
3C000044 # JUMP @ascii_comment
# ;; Deal with line comments starting with ;
A030003B # CMPSKIPI.NE R0 59
3C000050 # JUMP @ascii_comment
3C00003C # JUMP @ascii_comment
# ;; Deal with all ascii less than '0'
A0100030 # CMPSKIPI.GE R0 48
3C000054 # JUMP @ascii_other
3C000040 # JUMP @ascii_other
# ;; Deal with '0'-'9'
A0000039 # CMPSKIPI.G R0 57
3C000028 # JUMP @ascii_num
3C00001C # JUMP @ascii_num
# ;; Deal with all ascii less than 'A'
A0100041 # CMPSKIPI.GE R0 65
3C000044 # JUMP @ascii_other
3C000030 # JUMP @ascii_other
# ;; Unset high bit to set everything into uppercase
B00000DF # ANDI R0 R0 0xDF
# ;; Deal with 'A'-'F'
A0000046 # CMPSKIPI.G R0 70
3C000028 # JUMP @ascii_high
# ;; Deal with all ascii less than 'a'
A0100061 # CMPSKIPI.GE R0 97
3C000034 # JUMP @ascii_other
# ;; Deal with 'a'-'f'
A0000066 # CMPSKIPI.G R0 102
3C000010 # JUMP @ascii_low
3C000010 # JUMP @ascii_high
# ;; Ignore the rest
3C000028 # JUMP @ascii_other
3C000020 # JUMP @ascii_other
#:ascii_num 15c
#:ascii_num 150
11000030 # SUBUI R0 R0 48
0D01000E # JSR_COROUTINE R14
#:ascii_low 164
11000057 # SUBUI R0 R0 87
0D01000E # JSR_COROUTINE R14
#:ascii_high 16c
#:ascii_high 158
11000037 # SUBUI R0 R0 55
0D01000E # JSR_COROUTINE R14
#:ascii_comment 174
#:ascii_comment 160
42100100 # FGETC ; Read another char
A020000A # CMPSKIPI.E R0 10 ; Stop at the end of line
3C00FFF8 # JUMP @ascii_comment ; Otherwise keep looping
#:ascii_other 180
#:ascii_other 16c
0D000030 # TRUE R0
0D01000E # JSR_COROUTINE R14
#:finish 188
#:finish 174
2D201100 # LOADUI R0 0x1100 ; Close TAPE_01
42100002 # FCLOSE
2D201101 # LOADUI R0 0x1101 ; Close TAPE_02
@ -224,4 +213,4 @@ A020000A # CMPSKIPI.E R0 10 ; Stop at the end of line
FFFFFFFF # HALT
# ;; Where all of our pointers will be stored for our locations
#:table 19c
#:table 188

View File

@ -15,7 +15,7 @@
; along with stage0. If not, see <http://www.gnu.org/licenses/>.
:start
LOADUI R11 $table ; Where we are putting our address pointers
LOADUI R11 0x200 ; Where we are putting our address pointers
TRUE R12 ; Our toggle
FALSE R13 ; Our PC counter
LOADUI R14 $getLables_2 ; our first iterator
@ -179,24 +179,17 @@
;; Deal with all ascii less than 'A'
CMPSKIPI.GE R0 65
JUMP @ascii_other
;; Unset high bit to set everything into uppercase
ANDI R0 R0 0xDF
;; Deal with 'A'-'F'
CMPSKIPI.G R0 70
JUMP @ascii_high
;; Deal with all ascii less than 'a'
CMPSKIPI.GE R0 97
JUMP @ascii_other
;; Deal with 'a'-'f'
CMPSKIPI.G R0 102
JUMP @ascii_low
;; Ignore the rest
JUMP @ascii_other
:ascii_num
SUBUI R0 R0 48
JSR_COROUTINE R14
:ascii_low
SUBUI R0 R0 87
JSR_COROUTINE R14
:ascii_high
SUBUI R0 R0 55
JSR_COROUTINE R14

View File

@ -6,5 +6,5 @@ b3a910f18c6bc0ef4aa7a53cb3f0216a9f143319da67ed2a02210fe88b1e1131 roms/forth
24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET
0a427b14020354d1c785f5f900677e0059fce8f8d4456e9c19e5528cb17101eb roms/stage0_monitor
3ea7fed1429400c1d6fc5b85180c4114755dfb1e6b88d69e7ecc465a40523bc8 roms/stage1_assembler-0
e59338381ca3ab01a14fa0fc85d0fa1c6e4d59a06ac2d9d75668d878ab469769 roms/stage1_assembler-1
b6aabcc3418a0a28f4ed32ace43b20103d9d21dffae03e7936cb14fa0e044013 roms/stage1_assembler-1
61c1b0f2f628847d9491bd678ac7a23231527cc36493b321612f191674ff3c99 roms/stage1_assembler-2