[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Memory filling puzzle
>> ObAppleII: OK, here's a puzzle for you die-hard 6502 fans. You have
>> a 48k Apple ][ Plus with a 6502 processor and all slots empty. Your
>> goal is to write a program that will fill the whole RAM space ($0000
>> through $BFFF) with the same value (of your choice). You must not call
>> any routine in ROM. Your program must use only documented opcodes.
>> Good luck.
>
> Only one question: does it matter if the program hits the I/O space
> and then starts behaving unpredictably? If not, then it is easy. If
> it does matter, then I have some more thinking to do.
I like a challenge!
The method of attack I would use is to make a program that fills $00-FF,
and $200-BFFF with whatever the PHA opcode is. Then fall through to some
code in the stack space $100-1FF that would load the Yreg with stack ponter
to reset to top of stack, load the Areg with the PHA opcode again, store
it at $100, do a PHA and a JMP $100. Should fall through to the top of
the stack, which will be PHA, which will store a PHA at PC+1, and then
execution falls through to the newly pushed PHA. Thus the code "erases"
itself.
Of course execution will finally hit $C000 and go a bit berzerk.
Possibly there is a way to do something similar and fill the stack with
RTS's.... keep RTS'ing to $6060. Can't think of how to do it right now,
but it'd at least stop things from crashing. (hangs better than crashes??)
--
Nathan Fisher
FISHERN3485@COBRA.UNI.EDU