Date : Mon, 15 Aug 1994 10:48:00 EST
From : Stephen Quan <quan@...>
Subject: Re: Flags and BIT
Hi Chris, there are very significant differences between 80x86 and
the 6502. I have encountered many of these, but will try to summarize!
> 1. Are the flags set on the result of *every* operation? Even things like
> LDA? And what about, for example, PHA? Just wondering. I've been setting
> them on most instructions, just to be on the safe side.
The flag behaviour is described in the AUG. I think you can treat the
AUG as the 6502 bible in this respect [unless anyone knows anything
wrong here?]
LDA - will update N flag and Z flag.
PHA - will change no flags
> 2. Is the 6502 BIT instruction directly equivalent to the 80x86 TEST?
The short answer is no!
Ok now what I have noted between 6502 vs 80x86 (I continue at 3.) :
3. CMP instruction.
After a 6502 the C is set if A >= M
On a 80x86 the CF is cleared if A >= M
4. SBC
On a 6502 the C is cleared to indicate borrow
On a 80x86 the CF is set if we want borrow (nasty!)
5. LDA
On a 6502 changing your registers A,X,Y the NZ changes
On a 80x86 the MOV instruction does not update flags, you need to
run test immediately afterwards.
6. ROL and ROR
On a 6502 ROL and ROR are 9 bit rotates using the C as the 9th bit.
On a 80x86 ROL and ROR are 8 bit rotates.
On a 80x86 RCL and RCR are 9 bit rotates but don't set ZF.
7. BIT
I don't think there is an equivalent to this instruction. It is
just like the manual says. Let's say M represents the data then :
Z = set if (A&M) = 0, cleared otherwise
V = bit 6 of M
N = bit 7 of M
other flags aren't affected.
8. LSR and ASL
On a 6502 ASL multiplies by 2, very similar to SHL.
On a 6502 LSR divides by 2 (unsigned),
SHR on a 80x86 divides by 2 but is signed (double check manual...).
ROMs should be emulated to a degree. You can start of by trapping
writes to 8000-FFFF. Later you have to consider special cases such
as sideways RAM, on shiela pokes. The first key one is getting
FE30 writes working.
--
Stephen (quan@... )