[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SOS file system information



On 03/23/2011 09:33 PM, David Empson wrote:

> Early versions of ProDOS disk utilities write ProDOS boot code in block
> 0 and SOS boot code in block 1, relying on the different entry points.
> The Apple ][ expects byte 0 to be $01 and starts executing from byte 1.
> The Apple /// starts executing from byte 0. The $01 byte is an illegal
> opcode for the 6502, but it is parsed as if it is a three byte
> instruction (if I remember right). With some careful coding, this allows
> the initial sequence of instructions to diverge depending on whether you
> started executing at offset 0 or 1.

Nitpick: $01 is actually a legal opcode, namely the seldom-used

ORA ($zp,X)

Which is of course two bytes long. Effectively it will skip one byte on
the Apple III, which contains a SEC command for the Apple II. Then a BCS
happens, which will jump on the Apple II thanks to the preceding SEC.
The BCS skips a JMP which happens only on the Apple III.

Obviously for this scheme to work, it must be true that the Apple III
will always enter this code with the carry flag cleared, also the
Accumulator value must be unimportant since the ORA will clobber it.

-- 
Linards Ticmanis