Subject: Re: Nubus card debugging
To: Allen Briggs <briggs@wasabisystems.com>
From: David A. Gatwood <dgatwood@gatwood.net>
List: port-mac68k
Date: 08/05/2002 18:17:33
On Mon, 5 Aug 2002, Allen Briggs wrote:

> > Judging by that, the code is really, really overkill, and could be
> > reduced to eight accesses (four pairs) and two non-nested for loops.
> > 
> > char array[4];
> > 
> > for (i=1; i<=4; i++) {
> > 	array[4-i] = 0;
> > 	if (mac68k_bus_space_probe(base + size - i)) {
> > 		array[4-i] = inb(base + size - i);
> > 	}
> > }
> > 
> > for (i=1; i<16; i++) {
> > 	if (i<2) pos=1;
> > 	else if (i<4) pos=2;
> > 	else if (i<8) pos=3;
> > 	else pos=4;
> > 	if (array[i] == (~(i << 4) & 0xf0) | i) {
> > 		break;
> > 	}
> > }
> 
> Assuming you mean array[pos] instead of array[i] here, adjust for
> 0-based arrays w/o overrunning the end, and make array unsigned char
> instead of signed...  ;-)

D'oh!  Yeah, typing too fast.  The first part got the array indices right. 
The second part should have pos going from 0-3, not 1-4, and yes, I meant
array[pos].  As for unsigned char, char... doesn't char default to
unsigned on m68k and ppc?  :-)


Later,
David

---------------------------------------------------------------------
David A. Gatwood                                dgatwood@gatwood.net
Developer Docs Writer                             dgatwood@apple.com
Apple Computer                                  dgatwood@mklinux.org

                    Check out my weekly web comic:
                     http://www.techmagazine.org