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

Re: Introducing Slammer!



On 7/30/2010 11:52 AM, Ivan X wrote:
On Jul 27, 4:43 am, Ivan Drucker<i...@ivanx.com>    wrote:

the only instructions I had
available were AND BIT BMI BVC CLI EOR JMPa LSR PHA PLP ROL RTI.
(I used all but one of them.)

On Jul 30, 1:44 am, "Michael J. Mahon"<mjma...@aol.com>  wrote:
I'm guessing that it was BVC that went unused...?  ;-)

On 7/30/10 8:42 AM, in article
5491b850-7287-4c4f-81b3-dfed24773483@f42g2000yqn.googlegroups.com, "James
Littlejohn"<narguthru@yahoo.com>  wrote:

Just to prove that I was really listening to his presentation at
Kfest, the correct answer is JMPa.

Very good -- you get an A! For Accumulator. Actually, I was mistaken -- I
didn't use PLP either.

Actually, given only two branch instructions, and no JSR or JMP, I used BVC
often for branch always; I ensure the V flag is cleared at the beginning of
Slammer by performing BIT on a location with 0 in it, and nothing else
Slammer does changes it. (I'm actually going to post the Slammer source and
an explanation of how I did the whole thing shortly.)

I actually use the V flag regularly even in my normal machine language
programming, because it is affected by so few instructions (ADC, SBC, CLV,
BIT, PLP, RTI). This means I can use it as a binary state indicator (among
other things); you can clear it with CLV, or set it with BIT $B1 (on a II+
or later). A four-way state in bits 6 and 7 of a byte makes for easy
branching without CMP, as you just BIT it, and then use BPL/BMI and BVC/BVS
accordingly. And CLV-BVC is a branch always for 6502 that doesn't disturb
the other flags, which is especially useful when writing relocatable code
where you can't easily use JSR and JMP.

Thanks for that, Ivan!

I often use C in that way, and often it's state is known at a particular
point in the code, but I definitely underuse V.  From now on, I will
consider it more often!

-michael

NadaNet 3.1 for Apple II parallel computing!
Home page:  http://home.comcast.net/~mjmahon/

"The wastebasket is our most important design
tool--and it's seriously underused."