Classic Computer Magazine Archive COMPUTE! ISSUE 21 / FEBRUARY 1982 / PAGE 176

An Easy Way To Relocate VIC Programs On Other Commodore Computers

Greg Sherwood and Ross Sherwood
Manhattan, KS

BASIC programs that are generated on Commodore's new color computer, the VIC-20, start at memory location 4097 rather than at 1025 as in Commodore's other computers. Thus, if you wish to use features available for some of the other computers such as Toolkit, etc. to edit or modify a program written or stored from a VIC, you need to relocate the program so it starts at memory location 1025.

The following is a description of a quick and simple method of relocation of VIC programs, I will describe two versions, one using the built in monitor and the other done in direct mode.

To relocate a VIC program from the monitor, load the program from tape and then enter the monitor with SYS1024. Next, look at the first part of BASIC memory by typing M 0400 0400. Make the following changes to the displayed memory:

'M 0400 00 01 10 00 99 00 XX'
(XX means doesn't matter.)

Next exit the monitor by typing an X. Now type LIST and the VIC program should list out with an additional line (line 0) at the beginning: 0 PRINT Finally type "0" and RETURN and the VIC program is relocated and can be edited or modified at will.

To accomplish the same change in direct mode, the following six POKEs are entered:

POKE 1025,1:POKE 1026,16
 change link pointers to VIC program
POKE 1027,0:POKE 1028,0
 create line #0
POKE 1029,159
 put PRINT on line 0
POKE 1030,0
 end of line indicator

Now, as above, type LIST and the VIC program will list with the additional line 0 PRINT.

Last, type "0" and the line 0 will be eliminated so the VIC program can be edited.

This method works with both BASIC 3.0 and 4.0 Commodore computers and, through it hasn't been tested on other versions, it should work on those as well. It has been successfully used on both 40 and 80 column machines.

If you should wish to relocate several VIC programs in succession, the following assembly language subroutine can be used. It begins at location 926 in the second cassette buffer and can be called by SYS926. To load this program, enter the monitor and type M 039E 03C8 annd change the memory as follows:

039E A9 00 8D 03 04 8D 04 04
03A6 8D 06 04 A9 30 8D 6F 02
03AE A9 01 8D 01 04 A9 10 8D
03B6 02 04 A9 99 8D 05 04 A9
03BE 0D 8D 70 02 A9 02 85 9E
03C6 60 00 XX XX XX XX XX XX

This program can be saved on tape or disk by saving from 039E to 03C8 and then can be loaded in anytime and used to relocate VIC programs with a SYS926 command until the machine is turned off or the second cassette buffer is used for some other purpose. This subroutine is located high enough in the second cassette buffer that disk operations don't overwrite it.

This subroutine automatically erases line 0 and so that, when you return to BASIC, the VIC program is moved and ready to be edited, etc. without the necessity of removing line 0.

039E A9 00     LDA #$00
03A0 8D 03 04  STA $0403
03A3 8D 04 04  STA $0404
03A6 8D 06 04  STA $0406
03A9 A9 30     LDA #$30
03AB 8D 6F 02  STA $026F
03AE A9 01     LDA #$01
03B0 8D 01 04  STA $0401
03B3 A9 10     LDA #$10
03B5 8D 02 04  STA $0402
03B8 A9 99     LDA #$99
03BA 8D 05 04  STA $0405
03BD A9 0D     LDA #$0D
03BF 8D 70 02  STA $0270
03C2 A9 02     LDA #$02
03C4 85 9E     STA $9E
03C6 60        RTS
03C7 00        BRK
03C8 00        BRK