mirror of https://github.com/mist64/cbmsrc.git
Michael Steil
4 years ago
20 changed files with 7851 additions and 4 deletions
@ -0,0 +1,127 @@
|
||||
;*************************************************************************** |
||||
; C65 ASSEMBLER FOR C128 |
||||
;*************************************************************************** |
||||
; |
||||
version .macro ; DECLARE FOR DATE OF MODIFICATIONS |
||||
.byte "V3t5" |
||||
.endm |
||||
; |
||||
; REV_LIST |
||||
; |
||||
; WHO WHEN WHAT |
||||
; --- ---- ---- |
||||
; hcd 10/02/87 |
||||
; V3.5 added bank0_ram_max to global definitions, |
||||
; integrated into init_macro. |
||||
; ( gives 16k additional macro expansion space ) |
||||
; |
||||
; hcd 9/28/87 rewrote value_xyzzy which is really the integer divide |
||||
; V3.4 routine so that it was more clear, less brain damaged, |
||||
; less likely to hang, and hopefully now returns the |
||||
; correct result. |
||||
; |
||||
; hcd 7/27/87 1) corrected local labels so that leading zeros |
||||
; v3.3 are insignificant. This done in issymbollegal. |
||||
; 2) corrected bug where empty symbol table would |
||||
; make xref puke. |
||||
; 3) Caused xref and symbol table sort to be bypassed |
||||
; if no list channel or xref device. This saves |
||||
; time on object only assemblies. |
||||
; |
||||
; hcd 9/9/86 moved a page buffer from sprite buffers to basic run |
||||
; time stack to free sprite buffers for use with |
||||
; ramdisk. |
||||
; |
||||
; hcd 9/1/86 removed date string macro, and inserted version |
||||
; V3.0 string macro. This macro is tied to the |
||||
; listing format and the entry point which simply |
||||
; displayes the assemblers name and copyright message. |
||||
; |
||||
; hcd 8/15/86 removed code that disabled basic irqs, and |
||||
; simply caused interupts to be disabled over entire |
||||
; assembly process. |
||||
; |
||||
; moved error count to place where basic may PEEK it. |
||||
; |
||||
; made macro names case insenitive |
||||
; ( added TOUPPER call in directive_macro , and |
||||
; OPER_TOUPPER call in pass_a routine ) |
||||
; |
||||
; added date declares for version tracking |
||||
; |
||||
; moved CURRENT_SYMBOL to zero page for speed/codespace |
||||
; |
||||
; modified parse_macro_args_for_expansion to use |
||||
; tildes per BSO operation. |
||||
; |
||||
; changed IS_SYMBOL_DEFINED ( affects .ifdef,.ifndef ) |
||||
; to reply false for all symbols defined after |
||||
; the current line even though they are in the |
||||
; symbol table. |
||||
; |
||||
;*************************************************************************** |
||||
; |
||||
curzpg = $0a ; start of zero page variables ( lots of em too ) |
||||
zero_page_save_bot = $0a |
||||
zero_page_save_top = $8f |
||||
; |
||||
down_load_code_base = $0240 ; place for down loaded code |
||||
down_load_code_max = $02a2 ; first illegal down load addr |
||||
; |
||||
macro_args = $0B00 ; page_buffer in cassette buffer |
||||
storbuf = $0800 ; page buffer in basic run time stack |
||||
xref_buf = $0900 ; page buffer in basic run time stack |
||||
; |
||||
curram = $1300 ; start of normal ram variables |
||||
; |
||||
mmucr = $FF00 ; address of mmu cr register |
||||
mmucr_bank1_ram = %01111111 ; config for bank 1 ram only |
||||
mmucr_bank0_normal = %00001110 ; config for normal ops |
||||
; ( bank 0, kernal,io ) |
||||
bank0_ram_max = $bfff ; highest address for bank0 ram |
||||
; ; with mmucr_bank0_normal |
||||
symbol_table_start = $1000 ; base of symbol table in bank 1 |
||||
symbol_table_end = $FEFF ; end of symbol table in bank 1 |
||||
; |
||||
code_start = $1700 ; code is in bit map & bit map color map |
||||
; ; and even below that ... |
||||
; its every where, its everywhere |
||||
.include macros |
||||
.include kernal |
||||
; |
||||
.blist |
||||
.include global |
||||
*=code_start |
||||
jmp init |
||||
jsr $ff7d ; primm.... |
||||
.byte "(C)1986 COMMODORE ELECTRONICS, LTD.",cr |
||||
.byte "ALL RIGHTS RESERVED " |
||||
version |
||||
.byte cr,0 |
||||
rts |
||||
; |
||||
.include main |
||||
.include util |
||||
.include parse |
||||
.include opcode |
||||
.include eval |
||||
.include error |
||||
.include directive |
||||
.include ifendif |
||||
.include macro |
||||
.include input |
||||
.include output |
||||
.include symbol |
||||
.include xref |
||||
; |
||||
.ifgt *-$4000 |
||||
*** error *** code overlays start of basic |
||||
.endif |
||||
.ifgt curram-code_start |
||||
*** error *** allocated ram overlaps code |
||||
.endif |
||||
.ifgt curzpg-$90 |
||||
*** error *** allocated zeropage overlaps kernal area |
||||
.endif |
||||
; |
||||
.end |
@ -0,0 +1,83 @@
|
||||
; |
||||
; basic program interface variables |
||||
; |
||||
* = curram |
||||
list_channel *=*+1 0,4,5 etc 4 |
||||
error_channel *=*+1 0,4,5 etc 5 |
||||
object_channel *=*+1 0,4-30 6 |
||||
; |
||||
input_device_low *=*+1 8-11 8,9,10,11 |
||||
input_device_high *=*+1 8-11 |
||||
; |
||||
xref_device *=*+1 0,8,9,10,11 12 |
||||
xref_channel = 14 |
||||
list_channel_width *=*+1 = 40,80,132 13 |
||||
; |
||||
start_file_name *=*+17 ( null terminated string ) |
||||
date_string *=*+33 ( null terminated string ) |
||||
error_count *=*+2 ; return error count to basic |
||||
; |
||||
curram = * |
||||
; |
||||
; internal global variables. |
||||
; |
||||
zpage label,2 ; pointer to label strint |
||||
zpage oper,2 ; pointer to operand string |
||||
zpage arg,2 ; pointer to argument string |
||||
args = arg |
||||
zpage nargs ; number of arguments found |
||||
; |
||||
; |
||||
zpage pass ; pass 1 or pass 2 ? |
||||
zpage current_line,2 ; 16 bit current line number |
||||
zpage pc,2 ; 16 bit current pc value |
||||
zpage value,2 ; 16 evaluation value |
||||
ram valflg,1 ; quality of value |
||||
; |
||||
zpage list_line_count ; current line on page |
||||
ram page_number,2 ; current page number |
||||
ram conditional_depth ; depth of nested conditionals |
||||
ram macro_expansion_depth ; depth of macro expansions |
||||
ram formln ; number of lines per page |
||||
ram fatal_error ; caused by read errors, etc |
||||
ram end_flag |
||||
ram mid_line_pntr,2 ; pointer to midline string |
||||
; ( see list_page_header ) |
||||
; |
||||
line_max_len = 250 |
||||
ram line,line_max_len+1 ; input line |
||||
subttl_max_len = 132 |
||||
ram subttl,subttl_max_len+1 ; sub title for various pages |
||||
name_max_len = 16 ; users name for program.... |
||||
ram name,name_max_len+1 ; plus the trailing null |
||||
; |
||||
zpage bank1_pntr,2 ; pointer for bank 1 indirection |
||||
; |
||||
; |
||||
value_ok = %00000000 ; value ok |
||||
value_forward = %00000001 ; value forward reference |
||||
value_overflow = %00000010 ; value overflowed during calulations |
||||
value_undefined = %00000100 ; value is undefined |
||||
value_syntax = %00001000 ; evaluation syntax error |
||||
; |
||||
cr = 13 |
||||
lf = 10 |
||||
form_feed = 12 |
||||
tab = 9 |
||||
space = 32 |
||||
; |
||||
global_init .macro |
||||
lda #66 ; formln |
||||
sta formln |
||||
ldi $0000 |
||||
std current_line ; input source line |
||||
std error_count ; error counter |
||||
std pc ; pc |
||||
sta conditional_depth ; depth counter |
||||
sta macro_expansion_depth ; depth counter |
||||
sta subttl ; subttl |
||||
sta file_name ; filename |
||||
sta end_flag ; flag to indicate end statement |
||||
.endm |
||||
; |
||||
; |
@ -0,0 +1,187 @@
|
||||
|
||||
.page |
||||
.subttl ed1 editor initialization & I/O routines (04/29/85) |
||||
|
||||
;//////////////// E D I T O R J U M P T A B L E \\\\\\\\\\\\\\\\\ |
||||
*=$c000 |
||||
cint *=*+3 ;initialize editor & screen |
||||
disply *=*+3 ;display character in .a, color in .x |
||||
lp2 *=*+3 ;get a key from irq buffer into .a |
||||
loop5 *=*+3 ;get a chr from screen line into .a |
||||
k_print *=*+3 ;print character in .a |
||||
scrorg *=*+3 ;get size of current window (rows,cols) in .x, .y |
||||
scnkey *=*+3 ;scan keyboard subroutine |
||||
repeat *=*+3 ;repeat key logic & 'ckit2' to store decoded key |
||||
plot *=*+3 ;read or set (.c) cursor position in .x, .y |
||||
cursor *=*+3 ;move 8563 cursor subroutine |
||||
escape *=*+3 ;execute escape function using chr in .a |
||||
keyset *=*+3 ;redefine a programmable function key |
||||
irq *=*+3 ;irq entry |
||||
init80 *=*+3 ;initialize 80-column character set |
||||
swapper *=*+3 ;swap editor local variables (40/80 mode change) |
||||
window *=*+3 ;set top left or bottom right (.c) of window |
||||
|
||||
.page |
||||
.subttl c/128 KERNAL JUMP TABLE (04/29/85) |
||||
|
||||
;/////////////////// K E R N A L J U M P T A B L E \\\\\\\\\\\\\\\\\\\\ |
||||
|
||||
|
||||
* = $ff80-57 ;new 'jmps' for c/128 |
||||
|
||||
spin_spout *=*+3 ;setup fast serial port for input or output |
||||
close_all *=*+3 ;close all logical files for a given device |
||||
c64mode *=*+3 ;reconfigure system as a c/64 (no return!) |
||||
dma_call *=*+3 ;initiate dma request to external ram expansion |
||||
boot_call *=*+3 ;boot load program from disk |
||||
phoenix *=*+3 ;call all function card's cold start routines |
||||
lkupla *=*+3 ;search tables for given la |
||||
lkupsa *=*+3 ;search tables for given sa |
||||
_swapper *=*+3 ;swap to alternate display device (editor) |
||||
dlchr *=*+3 ;init 80-col character ram (editor) |
||||
pfkey *=*+3 ;program function key (editor) |
||||
setbnk *=*+3 ;set bank for load/save/verify |
||||
get_cfg *=*+3 ;convert bank to mmu configuration |
||||
jsrfar *=*+3 ;JSR to any bank, RTS to calling bank |
||||
jmpfar *=*+3 ;JMP to any bank |
||||
indfet *=*+3 ;LDA (fetvec),Y from any bank |
||||
indsta *=*+3 ;STA (stavec),Y to any bank |
||||
indcmp *=*+3 ;CMP (cmpvec),Y to any bank |
||||
_primm *=*+3 ;print immediate (always JSR to this routine!) |
||||
|
||||
.page |
||||
* = $ff80 ;conforms to c/64 jump table |
||||
|
||||
sys_rev *=*+1 ;release number of kernal (318020-04 rev 07/10/85) |
||||
|
||||
_cint *=*+3 ;init screen editor & display chips (editor) |
||||
ioinit *=*+3 ;init i/o devices (ports, timers, etc.) |
||||
ramtas *=*+3 ;initialize ram for system |
||||
restor *=*+3 ;restore vectors to initial system |
||||
vector *=*+3 ;change vectors for user |
||||
setmsg *=*+3 ;control o.s. messages |
||||
secnd *=*+3 ;send sa after listen |
||||
tksa *=*+3 ;send sa after talk |
||||
memtop *=*+3 ;set/read top of memory |
||||
membot *=*+3 ;set/read bottom of memory |
||||
key *=*+3 ;scan keyboard (editor) |
||||
settmo *=*+3 ;set timeout in ieee ?????????????????? unused ??????????? |
||||
acptr *=*+3 ;handshake serial byte in |
||||
ciout *=*+3 ;handshake serial byte out |
||||
untlk *=*+3 ;send untalk out serial |
||||
unlsn *=*+3 ;send unlisten out serial |
||||
listn *=*+3 ;send listen out serial |
||||
talk *=*+3 ;send talk out serial |
||||
readss *=*+3 ;return i/o status byte |
||||
setlfs *=*+3 ;set la, fa, sa |
||||
setnam *=*+3 ;set length and fn adr |
||||
__open *=*+3 ;open logical file |
||||
__close *=*+3 ;close logical file |
||||
__chkin *=*+3 ;open channel in |
||||
__ckout *=*+3 ;open channel out |
||||
__clrch *=*+3 ;close i/o channel |
||||
basin *=*+3 ;input from channel |
||||
bsout *=*+3 ;output to channel |
||||
loadsp *=*+3 ;load from file |
||||
savesp *=*+3 ;save to file |
||||
settim *=*+3 ;set internal clock |
||||
rdtim *=*+3 ;read internal clock |
||||
stop *=*+3 ;scan stop key |
||||
getin *=*+3 ;get char from queue |
||||
clall *=*+3 ;clear all logical files (see close_all) |
||||
clock *=*+3 ;increment clock |
||||
_scrorg *=*+3 ;return current screen window size (editor) |
||||
_plot *=*+3 ;read/set x,y coord (editor) |
||||
iobase *=*+3 ;return i/o base |
||||
; |
||||
; |
||||
init_status = $0a04 |
||||
; |
||||
; |
||||
.ifn 0 |
||||
|
||||
.page |
||||
.subttl c/128 BASIC JUMP TABLE (04/29/85) |
||||
|
||||
;/////////////////// B A S I C J U M P T A B L E \\\\\\\\\\\\\\\\\\\\ |
||||
; |
||||
*=$4000 |
||||
basic_hard_reset *=*+3 |
||||
basic_soft_reset *=*+3 |
||||
basic_irq *=*+3 |
||||
; |
||||
*=$af00 |
||||
; Format Conversions |
||||
|
||||
ayint *=*+3 ;convert f.p. to integer |
||||
givayf *=*+3 ;convert integer to f.p. |
||||
fout *=*+3 ;convert f.p. to ascii string |
||||
val_1 *=*+3 ;convert ascii string to f.p. |
||||
getadr *=*+3 ;convert f.p. to an address |
||||
floatc *=*+3 ;convert address to f.p. |
||||
|
||||
; Math Functions |
||||
|
||||
fsub *=*+3 ;MEM - FACC |
||||
fsubt *=*+3 ;ARG - FACC |
||||
fadd *=*+3 ;MEM + FACC |
||||
faddt *=*+3 ;ARG - FACC |
||||
fmult *=*+3 ;MEM * FACC |
||||
fmultt *=*+3 ;ARG * FACC |
||||
fdiv *=*+3 ;MEM / FACC |
||||
fdivt *=*+3 ;ARG / FACC |
||||
log *=*+3 ;compute natural log of FACC |
||||
int *=*+3 ;perform basic INT on FACC |
||||
sqr *=*+3 ;compute square root of FACC |
||||
negop *=*+3 ;negate FACC |
||||
fpwr *=*+3 ;raise ARG to the MEM power |
||||
fpwrt *=*+3 ;raise ARG to the FACC power |
||||
exp *=*+3 ;compute EXP of FACC |
||||
cos *=*+3 ;compute COS of FACC |
||||
sin *=*+3 ;compute SIN of FACC |
||||
tan *=*+3 ;compute TAN of FACC |
||||
atn *=*+3 ;compute ATN of FACC |
||||
round *=*+3 ;round FACC |
||||
abs *=*+3 ;absolute value of FACC |
||||
sign *=*+3 ;test sign of FACC |
||||
fcomp *=*+3 ;compare FACC with MEM |
||||
rnd_0 *=*+3 ;generate random f.p. number |
||||
|
||||
; Movement |
||||
|
||||
conupk *=*+3 ;move RAM MEM to ARG |
||||
romupk *=*+3 ;move ROM MEM to ARG |
||||
movfrm *=*+3 ;move RAM MEM to FACC |
||||
movfm *=*+3 ;move ROM MEM to FACC |
||||
movmf *=*+3 ;move FACC to MEM |
||||
movfa *=*+3 ;move ARG to FACC |
||||
movaf *=*+3 ;move FACC to ARG |
||||
|
||||
optab *=*+3 |
||||
drawln *=*+3 |
||||
gplot *=*+3 |
||||
cirsub *=*+3 |
||||
run *=*+3 |
||||
runc *=*+3 |
||||
clear *=*+3 |
||||
new *=*+3 |
||||
lnkprg *=*+3 |
||||
crunch *=*+3 |
||||
fndlin *=*+3 |
||||
newstt *=*+3 |
||||
_eval *=*+3 |
||||
frmevl *=*+3 |
||||
run_a_program *=*+3 |
||||
setexc *=*+3 |
||||
linget *=*+3 |
||||
garba2 *=*+3 |
||||
execute_a_line *=*+3 |
||||
.endif |
||||
|
||||
.page |
||||
; basic ram variables |
||||
; |
||||
text_top = $1210 |
||||
max_mem_0 =$1212 |
||||
; |
||||
|
@ -0,0 +1,168 @@
|
||||
.subttl 16 bit macro definitions |
||||
; |
||||
ram .macro %a,%b |
||||
.ifdef %a |
||||
.messg multiple definitions -> curram |
||||
.else |
||||
%a = curram |
||||
.ifb <%b> |
||||
curram = curram+1 |
||||
.else |
||||
curram = curram+%b |
||||
.endif |
||||
.endif |
||||
.endm |
||||
|
||||
zpage .macro %a,%b |
||||
.ifdef %a |
||||
.messg multiple definitions -> curram |
||||
.else |
||||
%a = curzpg |
||||
.ifb <%b> |
||||
curzpg = curzpg+1 |
||||
.else |
||||
curzpg = curzpg+%b |
||||
.endif |
||||
.ifgt curzpg-$100 |
||||
ERROR- too many zero page variables..... |
||||
.endif |
||||
.endif |
||||
.endm |
||||
; |
||||
; |
||||
; double precision macros |
||||
; |
||||
; |
||||
ldd .macro %a |
||||
lda %a ; x,a <= %a |
||||
ldx %a+1 |
||||
.endm |
||||
; |
||||
std .macro %a |
||||
sta %a ; %a <= x,a |
||||
stx %a+1 |
||||
.endm |
||||
; |
||||
cpd .macro %a |
||||
mactmp = %a |
||||
cpx %a+1 ; compare x,a with %a |
||||
.ifn >mactmp |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
cmp %a |
||||
.endm |
||||
; |
||||
; |
||||
cpi .macro %a |
||||
cpx #>%a ; compare x,a with #%a |
||||
bne *+4 |
||||
cmp #<%a |
||||
.endm |
||||
; |
||||
ldi .macro %a |
||||
lda #<%a ; x,a <= #%a |
||||
ldx #>%a |
||||
.endm |
||||
; |
||||
; |
||||
incd .macro %a |
||||
mactmp = %a |
||||
inc %a ; inc double precision %a |
||||
.ifn >mactmp |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
inc %a+1 |
||||
.endm |
||||
; |
||||
decd .macro %a |
||||
mactmp = %a |
||||
pha ; dec double precision %a |
||||
lda %a |
||||
.ifn >mactmp |
||||
bne *+5 |
||||
.else |
||||
bne *+4 |
||||
.endif |
||||
dec %a+1 |
||||
dec %a |
||||
pla |
||||
.endm |
||||
; |
||||
add .macro %a |
||||
cld ; add %a to x,a |
||||
clc ; ( carry is only good condition code ) |
||||
adc %a |
||||
pha |
||||
txa |
||||
adc %a+1 |
||||
tax |
||||
pla |
||||
.endm |
||||
; |
||||
sbd .macro %a |
||||
cld ; sub %a from x,a |
||||
sec ; ( carry is only good condition code ) |
||||
sbc %a |
||||
pha |
||||
txa |
||||
sbc %a+1 |
||||
tax |
||||
pla |
||||
.endm |
||||
; |
||||
cmpdr .macro %a,%b,%r ; double compare %a to %b using .%r |
||||
ld%r %a+1 |
||||
cp%r %b+1 |
||||
mactmp = %a |
||||
.ifn >mactmp |
||||
mactmp = %b |
||||
.ifn >mactmp |
||||
bne *+2+3+3 |
||||
.else |
||||
bne *+2+3+2 |
||||
.endif |
||||
.else |
||||
mactmp = %b |
||||
.ifn >mactmp |
||||
bne *+2+2+3 |
||||
.else |
||||
bne *+2+2+2 |
||||
.endif |
||||
.endif |
||||
ld%r %a |
||||
cp%r %b |
||||
.endm |
||||
; |
||||
cpa .macro %a |
||||
cmp %a |
||||
.endm |
||||
; |
||||
phd .macro |
||||
pha |
||||
txa |
||||
pha |
||||
.endm |
||||
; |
||||
pld .macro |
||||
pla |
||||
tax |
||||
pla |
||||
.endm |
||||
; |
||||
adad .macro %a |
||||
clc |
||||
adc %a |
||||
sta %a |
||||
mactmp = %a |
||||
.ifn >mactmp |
||||
bcc *+5 |
||||
.else |
||||
bcc *+4 |
||||
.endif |
||||
inc %a+1 |
||||
.endm |
||||
; |
Loading…
Reference in new issue