SAVEing machine code program
Moderator: Moderators
SAVEing machine code program
Hello everyone.
Ok, I know this is going to seem really obvious to you but it's not to me! My problem is I have LOADed a program and I want to SAVE it back to tape, when I LIST it has only one line "10 SYS(1039)". Of course the whole program is in memory but when I SAVE it only SAVEs line 10! I am using a 4032 PET. How can I save the whole 8K program?
Ok, I know this is going to seem really obvious to you but it's not to me! My problem is I have LOADed a program and I want to SAVE it back to tape, when I LIST it has only one line "10 SYS(1039)". Of course the whole program is in memory but when I SAVE it only SAVEs line 10! I am using a 4032 PET. How can I save the whole 8K program?
Here it is in brief:
power on
LOAD; program loads takes a few minutes
SAVE"NAME",1,1; writes to tape normally. Takes a few seconds
Now if I run it it will work at this point
power off then on again
LOAD"NAME",1,1; program loads takes a few seconds
RUN ;nothing happens.
LIST ;lists line 10 only because that is all that is saved!
The problem is the code is not being written to tape, only the one line in BASIC with the SYS(number) is being written. The ,1,1 does not make a difference. If I load and save a BASIC program it is fine.
power on
LOAD; program loads takes a few minutes
SAVE"NAME",1,1; writes to tape normally. Takes a few seconds
Now if I run it it will work at this point
power off then on again
LOAD"NAME",1,1; program loads takes a few seconds
RUN ;nothing happens.
LIST ;lists line 10 only because that is all that is saved!
The problem is the code is not being written to tape, only the one line in BASIC with the SYS(number) is being written. The ,1,1 does not make a difference. If I load and save a BASIC program it is fine.
Maybe it is copy protected?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
http://sleepingelephant.com/ipw-web/bul ... p&start=30
The above is a link to a topic on Vic rom code dumping which you could maybe modify to read and write the memory block you want if it is in a rom or something.
Please send some more information about what you are doing as I do not understand why a save command won't store the machine code.
How are you entering this machine code in the first place when you say you can get it to run?
Are you in using Vice emulator or on a real PET?
The above is a link to a topic on Vic rom code dumping which you could maybe modify to read and write the memory block you want if it is in a rom or something.
Please send some more information about what you are doing as I do not understand why a save command won't store the machine code.
How are you entering this machine code in the first place when you say you can get it to run?
Are you in using Vice emulator or on a real PET?
Vic20-Ian
The best things in life are Vic-20
Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
The best things in life are Vic-20
Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
You can save MC programs through the monitor. On a 4032 PET, you can enter the monitor by typing SYS 4 or SYS 1024 (you need an address with a zero, BRK, in it) which will drop you into the command prompt where you can type S "PROGRAMNAME", device, start-address, end-address+1.
To save the screen to disk on a 4032, use S "0: SCREEN",08,8000,8400.
To save your 8K program to tape, use S "PROGRAM",01,040F,2410 - or S "PROGRAM",01,0400,2401 if you want the BASIC stub as well, and the 8K includes it.
To save the screen to disk on a 4032, use S "0: SCREEN",08,8000,8400.
To save your 8K program to tape, use S "PROGRAM",01,040F,2410 - or S "PROGRAM",01,0400,2401 if you want the BASIC stub as well, and the 8K includes it.
Before save your programs, you must poked the memory positions 43,44, 45 and 46 with the correct value for the begin and end of program.
For example, your MC program are placed in memory between the position 5000 and 5192.
divide 5000/256=19.53125 then the rest multiply by 256 .53125x256=136. The same with the other number
divide 5192/256=20.28125 then the rest multiply by 256 .28125x256=72.
You poked 43,19 44,136 45,20 and 46,72 then save the program with save "name",8 for disk and save"name",1 for tape.
For load you must use load"name",8,1 or load"name",1,1
Finally, if the program change this pointers for protection, you can take the values from the tape buffer positions 829, 830, 831 and 832 respectively (only if loaded from a tape of course). The values are put at the begin of the charge, in the moment you see the name of the program loaded, break, and take the values you need.
For example, your MC program are placed in memory between the position 5000 and 5192.
divide 5000/256=19.53125 then the rest multiply by 256 .53125x256=136. The same with the other number
divide 5192/256=20.28125 then the rest multiply by 256 .28125x256=72.
You poked 43,19 44,136 45,20 and 46,72 then save the program with save "name",8 for disk and save"name",1 for tape.
For load you must use load"name",8,1 or load"name",1,1
Finally, if the program change this pointers for protection, you can take the values from the tape buffer positions 829, 830, 831 and 832 respectively (only if loaded from a tape of course). The values are put at the begin of the charge, in the moment you see the name of the program loaded, break, and take the values you need.
- Richardc64
- Vic 20 Drifter
- Posts: 33
- Joined: Mon Feb 01, 2010 3:55 pm
You can't just add ",1" after the Device # and expect SAVE to know what range of memory to save: it needs to be told.
For Basic programs, SAVE takes start and end+1 from the start-of-BASIC (location 43/44) and end-of-BASIC (45/46) pointers. You could POKE new values into those location and then SAVE"my program",1,1 but that causes problems if done within a Basic program. Try this, from Chapter 6 of Compute!s Programming the VIC:
1000 sys57809"name",1,1:rem 8,1 for disk
1010 poke193, sl:poke194,sh:rem low byte/high byte of start address
1020 poke174, el,poke175,eh:rem low byte/high byte of end address+1
1030 sys63109
edit: I see two answers were posted while I was typing.
For Basic programs, SAVE takes start and end+1 from the start-of-BASIC (location 43/44) and end-of-BASIC (45/46) pointers. You could POKE new values into those location and then SAVE"my program",1,1 but that causes problems if done within a Basic program. Try this, from Chapter 6 of Compute!s Programming the VIC:
1000 sys57809"name",1,1:rem 8,1 for disk
1010 poke193, sl:poke194,sh:rem low byte/high byte of start address
1020 poke174, el,poke175,eh:rem low byte/high byte of end address+1
1030 sys63109
edit: I see two answers were posted while I was typing.
"I am endeavoring, ma'am, to create a mnemonic memory circuit... using stone knives and bearskins." -- Spock to Edith Keeler