Date : Tue, 24 Nov 2009 14:46:14 +0100 (CET)
From : anders.carlsson@... (Anders Carlsson)
Subject: Quine
Mick Champion wrote:
> PHP /// save flags expecially carry
> ASL &4011 /// could change carry flag
> PLA /// return old flags
Actually you "download" the flags to the accumulator.
> LDA & 4011
And here you replace the contents of the accumulator with
the value at address &4011.
> ADC#0 /// add with carry as set before the ASL
> STA &4011
> RTS
Possibly what you want to do is this?
ASL &4011
PHP
LDA &4011
PLP
ADC #0
STA &4011
However, LDA affects N and Z but leaves C alone so in this
case it is not required.
Depending on what preceeds your code, you may actually want this:
PHP
ASL &4011
LDA &4011
PLP
ADC #0
STA &4011
A summary of the instructions used above:
ASL - changes N, Z and C
LDA - changes N, Z
ADC - takes C input, changes N, V, Z and C
STA - changes no flags
PHP - changes no flags
PLP - changes all flags
PLA - changes N, Z
I can't recall anyone posting a link to the instruction set,
so I'll contribute a non-Beeb one:
http://nesdev.parodius.com/6502.txt
Machine code is tricky. It took me ten years to get going, and
another five years before feeling safe enough to test the waters.
Best regards
--
Anders Carlsson