summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-09-21 13:31:39 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2020-09-21 13:31:39 -0400
commit9932fac52c0cac2e9e0e11c84dfdf99e0a87ebfb (patch)
treeff97b9288293614fefc6f3ed972c3db69cba6f6e /programs
parenteea04e3327972f052dcfb8ae0854b77f87d3d52f (diff)
- Fixed some issues with how structs, and unions were
handled. - Added a function called fix_symtree(), which when called. will rearrange the symbol tree based on the order they're declared in by the token stream. The reason I wrote this, was to make sure the symbol tree could be printed correctly. - Optimized print_symtree() to now use tail recursion. - Started adding all of the SuB Suite's structs.
Diffstat (limited to 'programs')
-rw-r--r--programs/sub-suite/declare.s81
-rw-r--r--programs/sub-suite/subasm.s4
-rw-r--r--programs/sub-suite/subeditor.s8
3 files changed, 80 insertions, 13 deletions
diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s
index 166197b..cd97b60 100644
--- a/programs/sub-suite/declare.s
+++ b/programs/sub-suite/declare.s
@@ -1,4 +1,70 @@
+; Structs, and unions.
+
+; Line struct.
+.struct ln
+ next .qword ; Pointer to next line.
+ tok .qword ; The tokens for this line.
+
+ bline .word ; Number of blank lines.
+ lnum .dword ; Line number.
+
+ addr .qword ; The address of this line.
+.endstruct
+
+; Token struct.
+.struct tok
+ ;ptype .byte ; Pointer type, 0 for token, -1 for end of token.
+ next .qword ; Pointer to next token.
+ id .byte ; Token ID.
+ type .byte ; Token type ID.
+
+ tabs .byte ; Number of tabs.
+ spaces .byte ; Number of spaces.
+ stab .byte ; Number of sub-token tabs.
+ sspace .byte ; Number of sub-token spaces.
+ digits .byte ; Number of digits.
+
+ .union ; Token value.
+ sym .qword ; Symbol.
+ str .qword ; String.
+ val .qword ; Value.
+ .endunion
+.endstruct
+
+; Fixup struct.
+.struct fix
+ next .qword ; Pointer to next fixup.
+
+ s .qword ; Unresolved symbol.
+ t .qword ; Token that used the unresolved symbol.
+
+ addr .qword ; Address of where it happened.
+.endstruct
+
+; Symbol struct.
+.struct sym
+ next .qword ; Pointer to next symbol.
+ prev .qword ; Pointer to previous symbol.
+ down .qword ; Pointer to child symbol.
+ up .qword ; Pointer to parent symbol.
+
+ val .qword ; Value of symbol.
+
+ strct .byte ; Flag that says this symbol is a struct, or union.
+ def .byte ; Flag that says this symbol has been defined.
+
+ name .qword ; Name of symbol.
+ id .word ; ID of symbol.
+.endstruct
+
+; Instruction struct.
+.struct instr
+ am .word ; Addressing modes.
+ op .byte ; Base value used to get the actual opcode.
+.endstruct
+
+
; Enums.
; I/O constants.
@@ -95,6 +161,7 @@ INDX2 = 1 << 11 ; Special case of INDX that uses the indirect table.
ZM2 = 1 << 12 ; Special case of Zero Matrix used by JMP, and JSR.
+
; RAM declarations.
; Linewrap table.
@@ -257,22 +324,22 @@ lexeme:
.res $100
; Symbol table.
-sym:
+symbol:
.res $8000
; Fixup table.
; Fixups are unresolved symbols.
-fix:
+fixup:
.res $2000
; ROM data declarations.
.org $A000
; String Literals/Constants.
-tok:
- .byte "dab"
-msg:
- .byte "oof, you divided a, and b on me.\n"
+;tok:
+; .byte "dab"
+;msg:
+; .byte "oof, you divided a, and b on me.\n"
ed_name:
.byte "SuBEditor"
@@ -714,7 +781,7 @@ cmd_srt:
.word list
.word asm
.word help
- .word inst
+ .word ins
.word run
.word set
diff --git a/programs/sub-suite/subasm.s b/programs/sub-suite/subasm.s
index ec58a40..3957caa 100644
--- a/programs/sub-suite/subasm.s
+++ b/programs/sub-suite/subasm.s
@@ -161,10 +161,10 @@ help:
nop ;
@end:
rts ; End of help.
-inst:
+ins:
nop ;
@end:
- rts ; End of inst.
+ rts ; End of ins.
run:
nop ;
@end:
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index aec613e..fdf1e4b 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -91,10 +91,10 @@ read:
bra read ; Keep looping.
parse:
- lda #0 ;
- tax ;
- jsr subasm ;
- bra start ;
+ and #0 ; Reset A.
+ tax ; Reset X.
+ jsr subasm ; Call SuBAsm, and start parsing this line.
+ bra start ; Go back to reading the keyboard.
getchar: