Bryan Parkoff wrote: > 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 Presumably each 'c' is a clock bit, i.e. a 1. Your method (and example) is wrong. After the ASL, the first byte in your example will be '0c1c1c00' (note that the low order bit is zero), because the ASL always shifts a zero into the low order bit. In order to get the correct value, you must use SEC then ROL instead of ASL. > 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. I don't quite understand the question. Are you asking how to split a single byte into two bytes for writing as 4-and-4 encoding? Assuming the bytes are written such that the odd numbered data bits are in the first disk byte (I'd have to look up Beneath Apple DOS to confirm): 1. Save a copy of the original data byte (e.g. PHA). 2. For the first disk byte, do LSR then ORA #$AA. 3. Restore the original data byte (e.g. PLA). 4. For the second disk byte, do ORA #$AA. -- David Empson dempson@actrix.gen.nz On Thu, 19 Dec 2002, Bryan Parkoff wrote: > Date: Thu, 19 Dec 2002 22:49:07 -0600 > From: Bryan Parkoff > 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