Code: Select all
2010 SYS21+256*PEEK(44)
However, I'm concerned that not all the necessary pointers may be set as necessary...I don't modify any variable pointer settings, nor do I change the "next line" pointer...
http://members.cox.net/mechdan/vic/genstub.asm
Here's the code:
Code: Select all
; public domain generalized BASIC stub by Isaac Kuo
;
; Written for dasm; generate with command:
;
; dasm genstub.asm -ogenstub.prg
processor 6502
.org $1001 ; for the unexpanded Vic-20 by default
basic: ; The BASIC line: 2010 SYS21+256*PEEK(44)
.word zeros ; link to next line
.word 2010 ; line number
.byte $9E ; SYS token
.byte $30 + (start%256)%100/10 ; offset digit
.byte $30 + (start%256)%10 ; offset digit
.byte $aa ; + token
.byte "2","5","6" ; 256
.byte $ac ; * token
.byte $c2 ; PEEK token
.byte "(","4","4",")" ; (44) points to start of BASIC
zeros:
.byte 0,0,0
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
SCREEN = 7680
WORKFROM = 78
WORKTO = WORKFROM+2
; - - - - - - - - - - - - - - - - - - - - - - - - - - -
start:
; copy code to desired address
ldy #0
lda 44
sty WORKFROM
sta WORKFROM+1 ; set source address
lda #>basic
sty WORKTO
sta WORKTO+1 ; set destination address
copyloop:
lda (WORKFROM),y
sta (WORKTO),y
iny
bne copyloop ; relative address branch
inc WORKFROM+1
inc WORKTO+1
lda #>endmain+1
cmp WORKTO+1
beq endloop ; relative address branch
jmp copyloop ; ABSOLUTE address jmp to the copied code...so you don't
; overwrite the copying code while running it...
; think about what happens if you're on an 8K+ VIC...
endloop:
; set various pointers to desired settings
lda #>basic
sta 44 ; set start of BASIC (to 4097)
lda #>SCREEN
sta 56 ; set limit of BASIC (to 7680)
sta $0288 ; set software screen (to 7680)
lda #150
sta 36866 ; set hardware screen to 7680, 22 cols --HARDCODED--
lda #240
sta 36869 ; set hardware screen to 7680, font to default
jmp beginmain ; ABSOLUTE address jmp to routine at desired copied location
beginmain:
; ---> INSERT CODE HERE <---
endmain:
rts
Note that after the first 256 bytes copied, the code branches to the COPY of the code. Without this, then there's a risk of overwriting the looping code...not good...
[edit: changed title from "generic" to "universal", to better convey the idea]