Date : Fri, 20 Mar 2009 00:34:23 -0000
From : tom@... (Tom Seddon)
Subject: BBC register shuffling
The following should do the trick, though it's all off the cuff. It
requires 1 byte of working storage and assuming your byte is in zero page
it's (I think...) 7 bytes shorter. I label the bits as follows:
B+: --RIDS10
M128: --DS2R10
R=reset, I=interrupt, D=density select, 2/1/0=drive select bits.
So, with comments showing value in A ("."=0, "-"=unknown):
PHA ; --RIDS10
AND #%00000011 ; ......10
STA TMP ; ......10
PLA ; --RIDS10
AND #%00101100 ; ..R.DS..
ASL A ; .R.DS...
ASL A ; R.DS....
BPL FINALIZE
ORA #%00000100 ; R.DS.R..
.FINALIZE
ORA TMP ; R.DS.R10
This always leaves drive select 2 reset (for obvious reasons) and bit 7
set to the old value of R (under the assumption the value doesn't matter).
If you can use self-modifying code, you can chop it down to 0 bytes of
working storage by replacing "ORA TMP" with "ORA #0" and using the
location FINALIZE+1 instead of TMP, though this would make the code 2
bytes longer (unless the code itself is in zero page of course).
--Tom
On Sun, 15 Mar 2009 17:48:34 -0000, Michael Firth <mfirth@...>
wrote:
> I'm looking to write some 6502 assembler to swap from the B/B+ 1770
> control
> register format of:
>
> Bit Meaning
> -----------------
> 7,6 Not used.
> 5 Reset drive controller chip.
> 4 Interrupt ?
> 3 Double density select (0 = double, 1 = single).
> 2 Side select (0 = side 0, 1 = side 1).
> 1 Drive select 1.
> 0 Drive select 0.
>
> to the Master control register format of:
>
> Bit Meaning
> -----------------
> 7,6 Not used.
> 5 Double density select (0 = double, 1 = single).
> 4 Side select (0 = side 0, 1 = side 1).
> 3 Drive select 2.
> 2 Reset drive controller chip.
> 1 Drive select 1.
> 0 Drive select 0.
>
> Obviously (assuming the value is to start and finish in A) something
> primitive like:
>
> PHA
> AND #&03
> STA temp_loc
> PLA
> PHA
> AND #&0C
> ROL A
> ROL A
> ORA temp_loc
> STA temp_loc
> PLA
> AND #&20
> ROR A
> ROR A
> ROR A
> ORA temp_loc
>
> would do the job, but does anyone have a better suggestion for the code?
>
> Thanks
>
> Michael
>
>
>
> _______________________________________________
> bbc-micro mailing list
> bbc-micro@...
> http://lists.cloud9.co.uk/mailman/listinfo/bbc-micro
--
--Tom