Re: Commented 1541-II DOS disassembly

From: smf <smf_at_null.net>
Date: Sat, 25 Aug 2018 11:09:23 +0100
Message-ID: <2f3b9ae7-7d6d-4dd2-dd25-5c259fa2a389@null.net>
https://en.wikipedia.org/wiki/Commodore_DOS#The_save-with-replace_bug


      he save-with-replace bug[edit
      <https://en.wikipedia.org/w/index.php?title=Commodore_DOS&action=edit&section=5>]

Commodore DOS also offers a "Save-with-Replace" command, which allows a 
file to be saved over an existing file without the need to 
first|SCRATCH|the existing file. This was done by prepending an|@|symbol 
to the file name during the|OPEN|or|SAVE|operation - for 
instance,|SAVE"@MY PROGRAM",8|. For years rumors spread, beginning with 
the 4040 drive, of a bug in the command's implementation. At first, this 
was denied by some commentators. Prizes were offered to prove the 
existence of the bug.^[1] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-whittern198507-1> 
By early 1985/Compute! <https://en.wikipedia.org/wiki/Compute!>/magazine 
advised readers to avoid using the command.^[2] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-compute198502-2> 
That year various authors independently published articles^[1] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-whittern198507-1> 
^[3] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-slaymaker198510-3> 
^[4] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-slaymaker198511-4> 
^[5] <https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-5> proving 
that the Save-with-Replace bug was real and including methods by which 
it could be triggered.

Affected devices included the single-drive 1541 and dual-drive 4040; the 
8050 and 8250 did not exhibit the issue.^[1] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-whittern198507-1> 
Some commentators suggested the bug could be avoided by always 
explicitly specifying the|0:|drive number when saving,^[3] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-slaymaker198510-3> 
though it was later shown that/any/disk operations without a drive 
number were sufficient to lead to the bug.^[6] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-6> The bug 
stemmed from the fact that the affected DOS implementations were 
modified versions of the DOS contained in earlier Commodore PET dual 
drives such as the 8050. This created a "phantom drive|1:|" on 
single-drive systems, resulting in the allocation of an unnecessary 
buffer under some conditions. Since the Save-with-Replace command used 
all five drive buffers, and because the method by which the "phantom" 
buffer was allocated did not meet specifications, this resulted in 
scrambled data being written to the disk under some conditions.

In September 1986, Philip A. Slaymaker published an article^[7] 
<https://en.wikipedia.org/wiki/Commodore_DOS#cite_note-7> describing in 
great detail the cause of the bug and providingpatches 
<https://en.wikipedia.org/wiki/Patch_(computing)>to the 1541 drive ROMs; 
readers with anEPROM <https://en.wikipedia.org/wiki/EPROM>burner could 
produce their own patched ROMs which could be swapped into the drive. 
Commodore was made aware of Slaymaker's findings, and while they never 
issued an official update for the original 1541's ROMs, they did fix the 
bug in Revision 5 of the 1571 ROMs, and also in the ROMs for the 1541-c 
and 1541-II drives. Although not supported by Commodore, it is known 
that the 1541-II firmware (but not that of the 1541-c) can also be used 
in an original 1541 drive by using EPROMs, which will fix the bug for 
that drive as well.


Philip A. Slaymaker's compute article is here

https://groups.google.com/forum/#!topic/comp.sys.cbm/2Ya1rrnjSzA


On 25/08/2018 08:43, Spiro Trikaliotis wrote:
> Hello,
>
> * On Fri, Aug 24, 2018 at 05:29:47PM +0200 silverdr@wfmh.org.pl wrote:
>   
>> I take the 251968-03 is the latest, right?
> According to https://spiro.trikaliotis.net/cbmrom, yes.
>
>> Do we remember where was the SAVE"@ problem fixed (in which version)?
> We might try to find it by limiting the search area.
>
> I know for sure that 901229-05 did not include it yet.
>
> The -06 ROM only added a patch to $EE40. Instead of JSR to $C8C6
> directly, it goes to $FF2F which adds a LDA #$FF, STA $51 before the
> JSR.
>
> I am not sure about the intention of this patch, but I doubt it has to
> do with the SAVE "@ bug.
>
> So, I tend to believe that one of the 251968-0x added the patch.
>
> Regards,
> Spiro.
>
Received on 2018-08-25 13:00:05

Archive generated by hypermail 2.2.0.