Re: [stella] Help (Timing problems?)

Subject: Re: [stella] Help (Timing problems?)
From: "Thomas Jentzsch" <tjentzsch@xxxxxx>
Date: Fri, 10 Aug 2001 10:04:27 +0200
Wade Brown wrote:
> Could someone please explain bit.w's functionality? I have a rather lame 6502 instruction set ref 
> (HTML page) which is for 7800 and does not show opcodes, among other things...

> Maybe someone out there has a link to a better opcode ref - If so I (and the list, no doubt) would 
> sure appreciate hearing about it.

Wizard posted a complete instruction set to the the list in February (Re: [stella] illegal 6502)

> Also, I assume the reason the .byte $2c opcode is being used is because the opcode is
> undocumented (or maybe just un-supported by DASM?) 

Hi Wade,
it's a totally legal opcode, which is used for something it wasn't thought for. 

In the 650x instruction set there are two BIT instructions, one for zeropage adresses (opcode $24) and another for absolute (2 byte) adresses (opcode $2c).

The zeropage BIT instruction has a total lenght of 2 bytes (one for the opcode and one for the address), the absolute BIT instruction is 1 byte longer, because of the 2 byte address.

(I use to call the absolute one bit.w, the w stands for WORD, or two bytes)

Now the trick:
By inserting the opcode for bit.w directly before a valid 2 byte instruction (i.E. LDA #LEFT_BOUND), the CPU does only  'see' and execute the bit.w instruction, using the two bytes of the following two byte instruction as the address (i.E. BIT $14a9, $14 = 20, $a9 = opcode for LDA immediate). It leaves the contents of the accumulator unchanged, and that's what we wanted.

The trick simply 'hides' the next two bytes (or one byte if you use $24, i.E. to skip a flag instruction like CLC, SEC, ...) from the CPU.

> If so, anyone out there know of any hacks
> to DASM to enable this and other un-supported 6507 mnemonics?

I did send an "illegal opcode"-supporting version of DASM the this list in February (Re: [stella] DASM (was: Qb: v0.04)). But for that trick, it's not neccessary.

Have fun!
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |

Jetzt und nur hier Ihr original PREMIERE WORLD SportPaket 
plus 100 Euro ExtraPramie:

Archives (includes files) at
Unsub & more at

Current Thread