<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 13 Oct 2008 22:37:20 +0100
From   : afra@... (Phill Harvey-Smith)
Subject: [Fwd: Re: *CONFIGURE Q]

Subject: Re: [BBC-Micro] *CONFIGURE Q
Date: Mon, 13 Oct 2008 22:36:19 +0100
From: Phill Harvey-Smith <afra@...>
To: Michael Firth <mfirth@...>
References: 
<89056F0D6B620444BE8677A5802EE49F060EA264@...><48EBCBAE.3000703
at aurigae.demon.co.uk><269382A7193A4E1B86A5F0643A336814@...> 
<48F281CE.9060101@...> 
<D014E111998944849D2D0B377513D94F@...>

Michael Firth wrote:

> It would appear so. From the BeebEm sources (included with the 
> installation):
> 
>   case 0x89: /* BIT Immediate */
>    if (MachineType==3) BITInstrHandler(ReadPaged(ProgramCounter++));
>    break;
> 
> and

Yep.

> INLINE static void BITInstrHandler(int16 operand) {
>  PSR&=~(FlagZ | FlagN | FlagV);
>  /* z if result 0, and NV to top bits of operand */
>  PSR|=(((Accumulator & operand)==0)<<1) | (operand & 192);
> } /* BITInstrHandler */
> 
> As you suspected, the BIT instruction is clearing the N and V flags in 
> all cases.
> 
> It looks like the fix may be a bit fiddly, because of the way the 
> instruction decoding is done.

What I ended up doing was to replicte the BITInstrHandler, as
BITInstrImmHandler so that it just changed the Z flag, and then changed
case 0x89 to call it instead of the original, this seems to work fine.

> I suspect the only fix is to add an extra parameter to the 
> BITInstrHandler function, which is a flag which is '1' if its an 
> immediate BIT.

I considdered doing that, but the above seemed to fit in better with
what was already there :)

> I may have a hack at this at some point, and try and build BeebEm with 
> the change.

I can post the change here if you want, what's the policy as regards
attachments (of the updated source file)on the group, I have sent the
fixed source file to BeebEm's maintainer.

Cheers.

Phill.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>