summaryrefslogtreecommitdiff
path: root/programs/sub-suite
diff options
context:
space:
mode:
Diffstat (limited to 'programs/sub-suite')
-rw-r--r--programs/sub-suite/declare.s238
-rw-r--r--programs/sub-suite/lexer.s24
-rw-r--r--programs/sub-suite/subeditor.s26
3 files changed, 193 insertions, 95 deletions
diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s
index 8054956..55ccc2b 100644
--- a/programs/sub-suite/declare.s
+++ b/programs/sub-suite/declare.s
@@ -113,9 +113,9 @@ scr_row:
.res 1
scr_col:
.res 1
-scr_trow:
+scr_str:
.res 1
-scr_tcol:
+scr_end:
.res 1
scr_ptr:
.res 2
@@ -148,9 +148,9 @@ end:
.res 8
bitmask:
.res 1
-scr_str:
+scr_trow:
.res 1
-scr_end:
+scr_tcol:
.res 1
wrapped:
.res 1
@@ -287,311 +287,387 @@ bits:
.byte $80, $40, $20, $10, $08, $04, $02, $01
-; Instruction mnemonics, and opcodes.
+; Instruction table.
; Format.
;
-; String : Mnemonic.
; 2 bytes: Addressing mode bits.
; 1 byte : Base value, used to generate the actual opcode.
-mne:
- .byte "ADC"
+inst:
+ ; ADC
.word IMM|ZM|ABS|BREG
.byte $01
- .byte "AND"
+ ; AND
.word IMM|ZM|ABS|BREG
.byte $41
- .byte "ASR"
+ ; ASR
.word IMM|ZM|ABS|BREG
.byte $62
- .byte "BCC"
+ ; BCC
.word REL
.byte $A0
- .byte "BCS"
+ ; BCS
.word REL
.byte $90
- .byte "BEQ"
+ ; BEQ
.word REL
.byte $B0
- .byte "BNE"
+ ; BNE
.word REL
.byte $C0
- .byte "BNG"
+ ; BNG
.word REL
.byte $80
- .byte "BPO"
+ ; BPO
.word REL
.byte $70
- .byte "BRA"
+ ; BRA
.word REL
.byte $F0
- .byte "BRK"
+ ; BRK
.word IMPL
.byte $69
- .byte "BVC"
+ ; BVC
.word REL
.byte $E0
- .byte "BVS"
+ ; BVS
.word REL
.byte $D0
- .byte "CLC"
+ ; CLC
.word IMPL
.byte $09
- .byte "CLI"
+ ; CLI
.word IMPL
.byte $29
- .byte "CLV"
+ ; CLV
.word IMPL
.byte $49
- .byte "CMP"
+ ; CMP
.word IMM|ZM|IND|INDY|ABS|BREG|INDX2
.byte $82
- .byte "CPB"
+ ; CPB
.word IMM|ZM|IND|INDY|ABS|INDX2
.byte $04
- .byte "CPS"
+ ; CPS
.word IMPL
.byte $00
- .byte "CPX"
+ ; CPX
.word IMM|ZM|IND|ABS
.byte $24
- .byte "CPY"
+ ; CPY
.word IMM|ZM|IND|ABS
.byte $44
- .byte "DEB"
+ ; DEB
.word IMPL
.byte $99
- .byte "DEC"
+ ; DEC
.word IMPL|ZM|ABS
.byte $84
- .byte "DEX"
+ ; DEX
.word IMPL
.byte $B9
- .byte "DEY"
+ ; DEY
.word IMPL
.byte $79
- .byte "DIV"
+ ; DIV
.word IMM|ZM|ABS|BREG
.byte $42
- .byte "INB"
+ ; INB
.word IMPL
.byte $A9
- .byte "INC"
+ ; INC
.word IMPL|ZM|ABS
.byte $A4
- .byte "INX"
+ ; INX
.word IMPL
.byte $C9
- .byte "INY"
+ ; INY
.word IMPL
.byte $89
- .byte "JMP"
+ ; JMP
.word ABS|IND|ZM2
.byte $00
- .byte "JSR"
+ ; JSR
.word ABS|IND|ZM2
.byte $20
- .byte "LDA"
+ ; LDA
.word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS
.byte $C2
- .byte "LDB"
+ ; LDB
.word IMM|ZM|ZMX|ZMY|IND|INDX|INDY|ABS
.byte $E2
- .byte "LDX"
+ ; LDX
.word IMM|ZM|IND|ABS
.byte $64
- .byte "LDY"
+ ; LDY
.word IMM|ZM|IND|ABS
.byte $A2
- .byte "LSL"
+ ; LSL
.word IMM|ZM|ABS|BREG
.byte $A1
- .byte "LSR"
+ ; LSR
.word IMM|ZM|ABS|BREG
.byte $C1
- .byte "MUL"
+ ; MUL
.word IMM|ZM|ABS|BREG
.byte $22
- .byte "NOP"
+ ; NOP
.word IMPL
.byte $EA
- .byte "ORA"
+ ; ORA
.word IMM|ZM|ABS|BREG
.byte $61
- .byte "PHA"
+ ; PHA
.word IMPL
.byte $8E
- .byte "PHB"
+ ; PHB
.word IMPL
.byte $AE
- .byte "PHP"
+ ; PHP
.word IMPL
.byte $6E
- .byte "PHX"
+ ; PHX
.word IMPL
.byte $EE
- .byte "PHY"
+ ; PHY
.word IMPL
.byte $CE
- .byte "PLA"
+ ; PLA
.word IMPL
.byte $9E
- .byte "PLB"
+ ; PLB
.word IMPL
.byte $BE
- .byte "PLP"
+ ; PLP
.word IMPL
.byte $7E
- .byte "PLX"
+ ; PLX
.word IMPL
.byte $FE
- .byte "PLY"
+ ; PLY
.word IMPL
.byte $DE
- .byte "ROL"
+ ; ROL
.word IMM|ZM|ABS|BREG
.byte $E1
- .byte "ROR"
+ ; ROR
.word IMM|ZM|ABS|BREG
.byte $02
- .byte "RTI"
+ ; RTI
.word IMPL
.byte $60
- .byte "RTS"
+ ; RTS
.word IMPL
.byte $50
- .byte "SBC"
+ ; SBC
.word IMM|ZM|ABS|BREG
.byte $21
- .byte "SEC"
+ ; SEC
.word IMPL
.byte $19
- .byte "SEI"
+ ; SEI
.word IMPL
.byte $39
- .byte "STA"
+ ; STA
.word ZM|ZMX|ZMY|IND|INDX|INDY|ABS
.byte $28
- .byte "STB"
+ ; STB
.word ZM|ZMX|ZMY|IND|INDX|INDY|ABS
.byte $48
- .byte "STX"
+ ; STX
.word ZM|IND|ABS
.byte $68
- .byte "STY"
+ ; STY
.word ZM|IND|ABS
.byte $08
- .byte "TAB"
+ ; TAB
.word IMPL
.byte $0A
- .byte "TAX"
+ ; TAX
.word IMPL
.byte $4A
- .byte "TAY"
+ ; TAY
.word IMPL
.byte $2A
- .byte "TBA"
+ ; TBA
.word IMPL
.byte $1A
- .byte "TSX"
+ ; TSX
.word IMPL
.byte $8A
- .byte "TXA"
+ ; TXA
.word IMPL
.byte $5A
- .byte "TXS"
+ ; TXS
.word IMPL|IMM
.byte $9A
- .byte "TXY"
+ ; TXY
.word IMPL
.byte $7A
- .byte "TYA"
+ ; TYA
.word IMPL
.byte $3A
- .byte "TYX"
+ ; TYX
.word IMPL
.byte $6A
- .byte "WAI"
+ ; WAI
.word IMPL
.byte $59
- .byte "XOR"
+ ; XOR
.word IMM|ZM|ABS|BREG
.byte $81
+; Mnemonic Table.
+mne:
+ .byte "ADC"
+ .byte "AND"
+ .byte "ASR"
+ .byte "BCC"
+ .byte "BCS"
+ .byte "BEQ"
+ .byte "BNE"
+ .byte "BNG"
+ .byte "BPO"
+ .byte "BRA"
+ .byte "BRK"
+ .byte "BVC"
+ .byte "BVS"
+ .byte "CLC"
+ .byte "CLI"
+ .byte "CLV"
+ .byte "CMP"
+ .byte "CPB"
+ .byte "CPS"
+ .byte "CPX"
+ .byte "CPY"
+ .byte "DEB"
+ .byte "DEC"
+ .byte "DEX"
+ .byte "DEY"
+ .byte "DIV"
+ .byte "INB"
+ .byte "INC"
+ .byte "INX"
+ .byte "INY"
+ .byte "JMP"
+ .byte "JSR"
+ .byte "LDA"
+ .byte "LDB"
+ .byte "LDX"
+ .byte "LDY"
+ .byte "LSL"
+ .byte "LSR"
+ .byte "MUL"
+ .byte "NOP"
+ .byte "ORA"
+ .byte "PHA"
+ .byte "PHB"
+ .byte "PHP"
+ .byte "PHX"
+ .byte "PHY"
+ .byte "PLA"
+ .byte "PLB"
+ .byte "PLP"
+ .byte "PLX"
+ .byte "PLY"
+ .byte "ROL"
+ .byte "ROR"
+ .byte "RTI"
+ .byte "RTS"
+ .byte "SBC"
+ .byte "SEC"
+ .byte "SEI"
+ .byte "STA"
+ .byte "STB"
+ .byte "STX"
+ .byte "STY"
+ .byte "TAB"
+ .byte "TAX"
+ .byte "TAY"
+ .byte "TBA"
+ .byte "TSX"
+ .byte "TXA"
+ .byte "TXS"
+ .byte "TXY"
+ .byte "TYA"
+ .byte "TYX"
+ .byte "WAI"
+ .byte "XOR"
+
; Command subroutine table.
cmd_srt:
diff --git a/programs/sub-suite/lexer.s b/programs/sub-suite/lexer.s
index dc5a3b0..3a856b5 100644
--- a/programs/sub-suite/lexer.s
+++ b/programs/sub-suite/lexer.s
@@ -119,11 +119,11 @@ ptok_dot:
ldb idx1 ; Get the directive ID.
cpb #7 ; Have we reached the end of the directive table?
beq @end ; Yes, so we're done.
- lda.w #dir ; Get pointer to the start of the directive table.
+ lda.w #dir ; No, so get the start of the directive table.
clc ; Prepare for a non carrying add.
adc.w idx2 ; Offset the pointer, by the length of the previous string.
pha.q ; Preserve the directive string pointer.
- jsr strcaseptr ; Is the lexeme buffer, the same as the directive string?
+ jsr strcaseg ; Is the lexeme buffer, the same as the directive string?
pla.q ; Get the directive string pointer back.
beq @found ; Yes, so create a new token.
inc idx1 ; No, so increment the directive ID.
@@ -156,10 +156,14 @@ ptok_min:
lda #EXPR_MINUS ; Set the expresion type to EXPR_MINUS.
bra ptok_expr ; Set up the token.
ptok_gt:
+
lda #EXPR_LOW ; Set the expresion type to EXPR_LOW.
bra ptok_expr ; Set up the token.
ptok_lt:
lda #EXPR_HIGH ; Set the expresion type to EXPR_HIGH.
+ bra ptok_expr ; Set up the token.
+ptok_pipe:
+ lda #EXPR_OR ; Set the expresion type to EXPR_OR.
ptok_expr:
lda #TOK_EXPR ; Set the lexeme type to TOK_EXPR.
sta lex_type ;
@@ -254,19 +258,23 @@ ptok_alph:
stb.q idx1 ; Reset the second index.
jsr set_lexptr ; Set up the lexeme buffer.
@isop_loop:
- lda.w #mne ; Get pointer to the start of the instruction table.
+ ldb idx1 ; Get the instruction ID.
+ cpb #OPNUM-1 ; Have we reached the end of the mnemonic table?
+ beq @end ; Yes, so we're done.
+ lda.w #mne ; No, so get the start of the mnemonic table.
clc ; Prepare for a non carrying add.
adc.w idx2 ; Offset the pointer, by the length of the previous string.
+ pha.q ; Preserve the mnemonic string pointer.
jsr strcaseg ; Is the lexeme buffer, the same as the mnemonic string?
+ pla.q ; Get the mnemonic string pointer back.
beq @found ; Yes, so create a new token.
- ldb idx1 ; No, so Get the instruction ID.
- cpb #OPNUM-1 ; Have we reached the end of the instruction table?
beq @end ; Yes, so we're done.
inc idx1 ; No, so increment the instruction ID.
@offset:
- lda #14 ; Get the base size of the instruction table.
- clc ; Prepare for a non carrying multiply.
- mul idx1 ; Multiply the base offset, by the instruction ID.
+ jsr strlen ; Get the string's length.
+ inc ; Add one to the length.
+ clc ; Prepare for a non carrying add.
+ adc.w idx2 ; Add the string offset to the current length
sta.w idx2 ; Save the offset in the third index.
bra @isop_loop ; Keep looping.
@found:
diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s
index 476f1cf..e624990 100644
--- a/programs/sub-suite/subeditor.s
+++ b/programs/sub-suite/subeditor.s
@@ -402,11 +402,12 @@ printc:
@update1:
jsr findend ; Find the end of the line.
sta rege ; Use it for redrawing the line.
- sta scr_row ; Set the row position to to the end of the line.
- jsr findst ; Find the start of the line.
- lda scr_row ; Get the start of the line.
+; sta scr_row ; Set the row position to to the end of the line.
+; jsr findst ; Find the start of the line.
+; lda scr_row ; Get the start of the line.
+ lda scr_trow ; Get the current row position.
@update2:
- sta regf ; Set the starting line, to the start of the line.
+ sta regf ; Set the starting line, to the current row position.
jsr rdrw_ln ; Redraw the line.
lda scr_trow ; Get the real row position back.
sta scr_row ;
@@ -620,7 +621,9 @@ back:
jsr update_pos ; and update it's position.
rts ; We are done.
@update:
- lda scr_row ; Set the line to start redrawing, to the start of the line.
+ lda (ptr3), y ; Are we at the end of the line?
+ beq @shift ; Yes, so skip redrawing.
+ lda scr_trow ; No, so set the line to start redrawing, to the line that the cursor is on.
sta regf ;
inc rege ; Set the redraw flag to true.
bra @shift ; Start shifting the line back.
@@ -939,10 +942,21 @@ update_ptr:
clc ; Clear the carry flag.
lda scr_row ; Add the cursor's line number,
adc scr_str ; with the starting line number to get the absolute line number.
- tay ; Place it in the Y regster for now.
mul #maxcol+1 ; Multiply the line number by the screen's max column count, plus 1.
clc ; Clear the carry flag.
adc scr_col ; Add the cursor's column number to get the screen index.
+; cmp.w #$2000 ; Is the index greater than, or equal to the end of the screen buffer?
+; bcc @end ; No, so we're done.
+;@wrap:
+; and #0 ; Reset the screen's starting line.
+; sta scr_str ;
+; sta regf ; Setup the starting line for rdrw_ln.
+; lda #maxrow ; Reset the screen's ending line.
+; sta scr_end ;
+; sta rege ; Setup the ending line for rdrw_ln.
+; jsr rdrw_ln ; Redraw the entire screen.
+; bra update_ptr ; Get the screen index.
+@end:
rts ; End of update_ptr.