<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 13 Oct 2008 22:11:18 +0100
From   : mfirth@... (Michael Firth)
Subject: *CONFIGURE Q

----- Original Message ----- 
From: "Phill Harvey-Smith" <afra@...>
To: <bbc-micro@...>
Sent: Monday, October 13, 2008 12:01 AM
Subject: Re: [BBC-Micro] *CONFIGURE Q


> Michael Firth wrote:
>>> I'll check to see what my 2 Masters machines have, I checked and they
>>> both have 3.20, however I just knocked up a flash adapter an a piece of
>>> stripboard and put the 3.50 from mess on it, installed it into my one of
>>> my Masters and it seems to work fine, sooo, it looks like it's an
>>> emulator bug which is odd to say the least !
>>>
>> Sounds like you've saved me a job for tomorrow :-)
>>
>> Now I guess the $1,000,000 question is what on earth is happening 
>> different
>> with *CONFIGURE in MOS 3.5 that breaks two different emulators!
>
> Ok, after much hacking around with the MESS debugger, once I modified
> the bbc master driver to allow it to work, I think I have tracked down
> the problem (at least for MESS), it revolves around the instruction at
> $8654 in the terminal rom which is :
>
> bit #$40
>
> As emulated this changes the Carry, Overflow & Negative flags which
> would be correct for all addressing modes EXCEPT immediate, acording to
> the instruction sheet in the "New Advanced User Guide", which states
> "When immediate addressing is used (available only on the 65c12) the V
> and N flags are unchanged".
>
> I suspect that BeebEm has exactly the same problem.
>
It would appear so. From the BeebEm sources (included with the 
installation):

   case 0x89: /* BIT Immediate */
    if (MachineType==3) BITInstrHandler(ReadPaged(ProgramCounter++));
    break;

and

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.

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 may have a hack at this at some point, and try and build BeebEm with the 
change.

Michael 
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>