Classic Computer Magazine Archive PROGRAM LISTING: 88-02/FASTSTCK.M65


0100 ; FAST STACK
0110 ; BY BILL BODENSTEIN
0120 ; (c)1987, ANTIC PUBLISHING
0130 ;
0140 ;EQUATES
0150 ;
0160 PORTB = $D301   ;Toggle ROM
0170 BASIC.ON = 253
0180 BASIC.OFF = 255
0190 ;
0200 LDA =   165     ;Decimal opcode
0210 STMCUR = $8A    ;BASIC line ptr
0220 FORLN = $A0     ;Line # put here
0230 ;
0240 PUT.PATCH1 = $A071 ;Patch after
0250 ;                   STOP/END
0260 PUT.PATCH2 = PUT.PATCH1+5
0270 ;
0280 ;               Relocatable, but
0290     *=  $0600   ;could be called
0300 ;                via USR(1536)
0310 STARTCODE
0320     PLA         ;Remove # args
0330 COPY.BASIC
0340     LDA #$A0    ;Start of BASIC
0350     STA $E1
0360     LDA #$00
0370     STA $E0
0380     TAY 
0390 LOOP1
0400     LDX #BASIC.ON
0410     STX PORTB   ;BASIC ROM on
0420     LDA ($E0),Y ;Get a byte
0430     LDX #BASIC.OFF
0440     STX PORTB   ;BASIC RAM on
0450     STA ($E0),Y ;Copy byte
0460     INY 
0470     BNE LOOP1   ;And loop
0480 ;
0490     INC $E1
0500     LDA $E1
0510     CMP #192    ;Until all moved
0520     BNE LOOP1
0530 ;
0540 MODIFY.BASIC
0550     LDA #STMCUR+1 ;LDA ($8A),Y=>
0560     STA $B6C6   ;  LDA  $8B
0570     LDA #LDA    ;  and LDA $8A
0580     STA $B6C0
0590     STA $B6C5
0600 ;
0610     LDA # <PUT.PATCH2
0620     STA $BDCC   ;Change JSR from
0630     LDA # >PUT.PATCH2
0640     STA $BDCD   ;$B816 to patch2
0650 ;
0660 ;Install patch to re-enable ROM
0670 ;at STOP or END, and patch to
0680 ;change line pointer.
0690     LDX #ENDCODE-PATCH1-1
0700     LDY #ENDCODE-STARTCODE-1
0710 LOOP2
0720     LDA ($D4),Y ;Move bytes from
0730     STA PUT.PATCH1,X ;USR code
0740     DEY 
0750     DEX 
0760     BPL LOOP2   ;Done when patch
0770 ;
0780     RTS         ;installed
0790 ;
0800 ;Patches to be placed in code
0810 ;after STOP/END. Note: once
0820 ;BASIC ROM is enabled by patch1,
0830 ;patch2 won't be executed.
0840 PATCH1
0850     LDX #BASIC.ON
0860     STX PORTB
0870 ;
0880 PATCH2
0890     LDA FORLN   ;Ln addr is here
0900     STA STMCUR  ;Point to it
0910     LDA FORLN+1
0920     STA STMCUR+1
0930     LDY #2      ;(Rest is the
0940     LDA (STMCUR),Y ; same)
0950     STA $9F
0960     CLC 
0970     RTS 
0980 ENDCODE

Back to previous page