[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrong Value From Two Bytes -- Encoding



    Previous newsgroups show incorrect value.  For example, you put value
#C1 before #C1 goes into EA and EB.  If you want to restore from two bytes
into one byte, you will get value #C0 instead of #C1.  It is not correct.
Please take a look at your code below and try to figure out why.

       LDA #0
loop:  STA $27
wait1: LDA $c08c,x
       BPL wait1
       ROL ;            shift value to the left
       STA $26
wait2: LDA $c08c,x
       BPL wait2
       AND $26;         and value
       STA $002c,y
       EOR $27;         check"sum" (i.e. checkeor :-) )
       DEY
       BPL loop



On Thu, 19 Dec 2002, Bryan Parkoff wrote:

> Date: Thu, 19 Dec 2002 22:49:07 -0600
> From: Bryan Parkoff <BParkoff@satx.rr.com>
> Newsgroups: comp.sys.apple2
> Subject: 4-4 Format for GCR Question
>
> 4-4 Format for GCR Question
>
>     I know how to use ASL and AND opcode to put two bytes into one byte.
>
> For example:
>
> c0 c1 c1 c0
> c1 c1 c1 c0
>
> With ASL
>
> 0c 1c 1c 0c
> c1 c1 c1 c0
>
> With AND
>
> 01111100
>
>     It is how I can see above.  My question is -- How can I add '1' to
each
> bit before one byte can become two bytes?  Which instruction (opcode) do I
> use?  Please advise.
>
> --
> Yours Truly,
>
> Bryan Parkoff
> BParkoff@satx.rr.com
>
Hi,

sorry, I'm not sure what you mean. Are you referring to the odd even format?
If not, don't read the following. :-)

DOS 3.3 uses the odd even format to store the sector information in the
sector header (track, sector etc). At address $b96d it reads (Y = 3):
       LDA #0
loop:  STA $27
wait1: LDA $c08c,x
       BPL wait1
       ROL ;            shift value to the left
       STA $26
wait2: LDA $c08c,x
       BPL wait2
       AND $26;         and value
       STA $002c,y
       EOR $27;         check"sum" (i.e. checkeor :-) )
       DEY
       BPL loop

Shift and AND as you've written.

Writing is done at address $bcc4 (A = byte):

       PHA ;            put byte on stack
       LSR ;            first shift bits to the right
       ORA $3e;         $3e contains the value #$aa (s.b.)
       STA $c08d,x; write to latch
       CMP $c08c,x;     write byte
       PLA ;            restore byte
       NOP ;            time delay
       NOP
       NOP
       ORA #$aa;        this is probably what you were looking for
       NOP ;            time delay
       NOP
       PHA
       PLA
       STA $c08d,x;     write to latch
       CMP $c08c,x;     write byte
       RTS

Hope, this helps.

Holger


--
Yours Truly,

Bryan Parkoff
BParkoff@satx.rr.com