-
Notifications
You must be signed in to change notification settings - Fork 4
/
Pack Utility.65s
282 lines (218 loc) · 9.73 KB
/
Pack Utility.65s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
; Utility to pack large ASCII text - expecially if has lots of space and hash
;for VERSION 2.10
.OPT proc65C02,swapbin ;Michal Kowaski Simulator
.START START ;version 1.3.2
.IO_WND 80,25
IMV ='#' ;Indicates immediate mode value
HEX ='$' ;Indicates a hex value
OPEN ='(' ;Open bracket for indirect addressing
CLOSE =')' ;Close bracket for indirect addressing
PCREL ='*' ;Indicates PC relative addressing
LOBYTE ='<' ;Indicates lo-byte of following word
HIBYTE ='>' ;Indicates hi-byte of following word
PLUS ='+' ;Plus in simple expressions
MINUS ='-' ;Minus in simple expressions
DOT ='.' ;Indicates a local label
QUOTE =$27 ;delimits a string
COMMA =','
CMNT =';' ;indicates a full line comment
PROMPT ='.' ;The assembler prompt character
DASH ='-' ;Dash for crued graphics
EOL =$00 ;End of line marker
EOS =$00 ;End of string marker
EOFLD =$01 ;End of field in tokenised source line
BLANK =$02 ;used to mark a blank line
PRGEND =$FE ;used to flag end of program parsing
FAIL =$FF ;used to flag failure in various searches
CR =$0D ;CR character
ESC =$1B ;ESC character
BELL =$07 ;BELL should be $07 but $20 for testing
BS =$08 ;Back space key
TAB =$09 ;TAB character
LF =$0a ;Line feed
SP =$20 ;Space
;suspectiable to change as ROM's are generated.
STRING = $F5F0
WRCSI = $F651
RDCHAR = $F6EA
HEX2BIN = $F70E
RD2HEX = $F6FF
RD1HEX = $F6FA
SCAN_ESC = $F6DD
WRWORD = $F6D0
WR2HEX = $F6BA
DRAWLINE = $F6AB
WRCHAR = $F695
WRCRLF = $F645
WRDECI = $E76A
WRSPACE = $F691
CMD_AUT = $E81B
IN_BLANK = $EC26
NNONSPC = $E565
;complier flags
BRKAS2 = 0 ;Add a second BRK byte
MYWYM = 1 ;has MYWYM Board settings/Chips
LCD_ROUTINES = 0 ;Compile with LCD 16x2 lines
SYMON = 0 ;used for SYMON to define CIA and VIA
;special memory locations
USERKEYDEF = $f6 ;User defined @keys
CMD_CHR = $C5 ;First character of command
ERROR = $C6
IN = $0E
;*= $40
; General purpose registers
NEG_FLAG = $40 ;Negative flag (if <> 0)
COUNT = $41 ;GP counter
DELIM = $42 ;String/ASCII delimiter
HEXVAL = $43 ;16-bit value of expression
LEAD0 = $45 ;Leading 0 flag
CHAR = $46 ;Character compilation register
MULDIV = $48 ;Multiply/divide temp
EXP_SAVE = $4a ;Expression save value
DEC_SAVE = $4c ;Decimal convert save value
SAVE_Y = $4d ;Save Y pointer
LENG = $4f ;Length of block move
SRCE = $51 ;Source for block move
DEST = $53 ;Destination for block move
SAVE_X = $55 ;Save X pointer
;------------------------------------------------------------------------
; My board settings
;------------------------------------------------------------------------
.IF MYWYM
.IF SYMON
VIA = $8000 ;My board settings
ACIA = $8800
.ELSE
VIA = $4000 ;My board settings
ACIA = $6000
.ENDIF
ADATA = ACIA ;ACIA 6551 definations
ASTAT = ADATA +1
ACMND = ADATA +2
ACTRL = ADATA +3
REGB = VIA ;VIA 6522 definations
REGA = REGB +1
DIRB = REGB +2
DIRA = REGB +3
TICL = REGB +4
TICH = REGB +5
ACR = REGB +$B
PCR = REGB +$C
IFR = REGB +$D
IER = REGB +$E
.ELSE
;------------------------------------------------------------------------
; Simulator or HARDWARE Mapping 6502 Simulator
;------------------------------------------------------------------------
VIA = $8000
ACIA = io_area
io_cls = io_area + 0 ;writing to this clears the output window
io_putc = io_area + 1 ;a "glass teletype" output window. BS, CR and LF are actioned
io_putr = io_area + 2 ;raw output, bytes are output as their
;characters and not actioned.
io_puth = io_area + 3 ;hex output, bytes are output as their hex code
io_getc = io_area + 4 ;SCAN_ESCing character get, will wait for input
io_posx = io_area + 5 ;set cursor x position by writing here
io_posy = io_area + 6 ;set cursor y position by writing here
KBD = io_getc ;Keyboard input register
KBDCR = io_getc ;Keyboard control register
.ENDIF
;------------------------------------------------------------------------
; Start Here
; 100c cccc Space
; 110c cccc DELIM
; 101c cccc OTHER
;
;---------------------------------------------------------------------
*= $1000
START
lda #<trace ;klocation for text area to pack
sta SRCE
lda #>trace
STA SRCE +1
LDA #00
STA DEST
LDA #$20
STA DEST+1 ;$2000 location to store
;---------------------------------------------------------------------
PACK1 LDY #0
.LOOP LDA (SRCE),y
BEQ .eol ;ends with a ZERO
CMP #SP
beq .pack
CMP #DASH
BEQ .pack
CMP #'_'
BEQ .pack
JSR BUMPSOURCE
.WRITE STA (DEST),Y ;Save normal character
JSR BUMPDEST
BRA .LOOP ;Always taken!
.pack STA DELIM ;Save character to pack
LDA #1 ;Init repetition counter
STA COUNT
.PCKLOOP JSR BUMPSOURCE ;Count number of same characters
LDA (SRCE),y
CMP DELIM
BNE .PCKEXIT ;It's not the same anymore!
INC COUNT ;Increment counter
LDA COUNT ;Don't allow it to exceed 63
CMP #31
BCC .PCKLOOP ;Still OK!
NOP
JSR BUMPSOURCE ;Compensate for normal exit
.PCKEXIT LDA DELIM ;Was it space or dash?
CMP #' ' ; (Makes A=0 if it is space
BEQ .SPACE ;It was space!
CMP #DASH
BEQ .DASH
LDA #%10100000 ;Set _ flag
BRA .ADDCOUNT
.DASH LDA #%10100000 ;Set dash flag
BRA .ADDCOUNT
.SPACE LDA #%11100000
.ADDCOUNT ORA COUNT ;Combine with counter
BRA .WRITE
.eol RTS
;-----------------------------------------------------------------------------
BUMPSOURCE INC SRCE
BNE .skipbump
INC SRCE+1
.skipbump RTS
;-----------------------------------------------------------------------------
BUMPDEST INC DEST
BNE .skipbump
INC DEST+1
.skipbump RTS
;-----------------------------------------------------------------------------
trace
.ASCII " _______ ______ _______ ______ _______ ",CR,LF
.ASCII "|_ _| __ | _ | | ___| AC=",EOS
; .ASCII " _____ __ __ _____ _____ _____ _____ ___ ___ ",CR,LF
; .ASCII "| __| | | __| | | | | _| _| LOWER limit: ",EOS
; .ASCII "|__ |_ _|__ | | | | | | | | | . |_ | TOTAL RAM: ",EOS
; .ASCII "|_____| |_| |_____|_|_|_|_____|_|___|___|___| UPPER spent: ",EOS
help .ASCII CR
.ASCII " _______ _______ _____ ______ __ ",CR,LF
.ASCII " | | || ___|| | | __ \| |",CR,LF
.ASCII " | || ___|| |_ | __/|__| @ User defined command",CR,LF
.ASCII " |___|___||_______||_______||___| |__| A Auto line numbering",CR,LF
.ASCII " B Break command",CR,LF
.ASCII " EXPANSION PORT LOW EXPANSION PORT TOP C Copy command",CR,LF
.ASCII " +-------------------+ +-------------------+ D Dissassembler",CR,LF
.ASCII " |[]GND +5V[]| |[]PA0 IRQ[]| I ASCII Dump",CR,LF
.ASCII " |[]A12 +5V[]| |[]PA1 NMI[]| L List command",CR,LF
.ASCII " |[]A7 NC[]| |[]PA2 R/W[]| M Memory command",CR,LF
.ASCII " |[]A6 A8[]| |[]PA3 02[]| N New command",CR,LF
.ASCII " |[]A5 A9[]| |[]PA4 CA1[]| O Old command",CR,LF
.ASCII " |[]A4 A11[]| |[]PA5 PB5[]| R Renumber command",CR,LF
.ASCII " |[]A3 GND[]| |[]PA6 PB6[]| S Start assembling",CR,LF
.ASCII " |[]A2 A10[]| |[]PA7 PB7[]| T Trace code",CR,LF
.ASCII " |[]A1 CS[]| +-------------------+ V Value command",CR,LF
.ASCII " |[]A0 D7[]| G Go command",CR,LF
.ASCII " |[]D0 D6[]| HARDWARE MAPPING Y Memory configuraion",CR,LF
.ASCII " |[]D1 D5[]| E Erase line",CR,LF
.ASCII " |[]D2 D4[]| CS $2000 Z Clear Screen",CR,LF
.ASCII " |[]GND D3[]| VIA $4000 W Display Register",CR,LF
.ASCII " +-------------------+ ACIA $6000",CR,LF, EOS
*= $3000