Has (over)writing files via Assembly's SAVE changed between R41 and R46?

This is the starting place for reporting bugs to the team. We will pass bug reports on to the developers after validating the reports.

You can report bugs in hardware, operating system (KERNAL or BASIC ROMs), the emulator, or the Demo library. For bugs specific to downloaded programs, use the download forum.
Post Reply
ShawnL624
Posts: 10
Joined: Mon Jan 16, 2023 5:19 pm

Has (over)writing files via Assembly's SAVE changed between R41 and R46?

Post by ShawnL624 »

I have code that loads a file, changes the loaded data, and writes it back into the same file. I noticed when I moved to R46, it will save the file if it doesn't exist, but doesn't appear to overwrite the file if it does. (R45 behaves the same as R46, but I haven't tried with earlier versions.) I've attached a small .asm that shows what I'm seeing.

In R41, I see something like this when I run the PRG multiple times (assuming there is no HISCORE.BIN in the directory when I start). First run makes the file; the second run loads, changes, and saves; the third run sees the second's output, etc:

Code: Select all

LOAD"SAVETEST.PRG",8,1
RUN
00000000 -> 00001000
RUN
00001000 -> 00002000
RUN
00002000 -> 00003000
RUN
00003000 -> 00004000
In R45, R46 (again, I haven't tested R42, R43, or R44), it seems like the file will get created, but subsequent attempts to update it do not work:

Code: Select all

LOAD"SAVETEST.PRG",8,1
RUN
00000000 -> 00001000
RUN
00001000 -> 00002000
RUN
00001000 -> 00002000
RUN
00001000 -> 00002000
I checked through the release notes and didn't see anything specifically about this. So, I wanted to see if this was expected and/or what I'm doing wrong.

Cheers!
Attachments
savetest.asm
(2.81 KiB) Downloaded 223 times
Ed Minchau
Posts: 483
Joined: Sat Jul 11, 2020 3:30 pm

Re: Has (over)writing files via Assembly's SAVE changed between R41 and R46?

Post by Ed Minchau »

Yeah, you missed a change in I believe r42. Now, if you want to overwrite a file, the filename needs @: prepended. So, if your file is TEST.BIN to overwrite it you'd need to use @:TEST.BIN instead.
ShawnL624
Posts: 10
Joined: Mon Jan 16, 2023 5:19 pm

Re: Has (over)writing files via Assembly's SAVE changed between R41 and R46?

Post by ShawnL624 »

Thank you!
TomXP411
Posts: 1720
Joined: Tue May 19, 2020 8:49 pm

Re: Has (over)writing files via Assembly's SAVE changed between R41 and R46?

Post by TomXP411 »

Yep, Ed's correct.

Commodore disk drives have always had overwrite protection: they will fail with an error, and a blinky drive LED, if you try to save to a filename that already exists.

The solution is to use save-and-overwrite: prepend @: to your filename.

This has always existed in CBM-DOS, and it was added to the Host FS and CMDR-DOS drivers to make HostFS and CMDR-DOS consistent with Commodore and CMD drives.

Also of note: https://en.wikipedia.org/wiki/Commodore ... eplace_bug

There's also another feature of save-and-replace that's not often talked about: from one article I read, save-and-replace writes the replacement file before removing the old version of the file. So never save-and-replace if you don't have room for a second copy of the file you're saving.
Post Reply