Bug in Ford's nkbd driver

Michael "Ford" Ditto ditto at cbmvax.UUCP
Tue Nov 1 06:51:37 AEST 1988


In article <381 at uncle.UUCP> jbm at uncle.UUCP (John B. Milton) writes:
 [ about nkbd ]
>To get it to work, I changed (in ldkout):
>	if (!(*C_CMND_ADDR & 2)) {
>to
>	if (!((ushort)*C_CMND_ADDR & 0x200)) {

Yeah!  That's it, all right!  It was just a bug in the human decompiler.
The cast isn't necessary, just change 2 to 0x200 (C_CMND_ADDR is already
a pointer to ushort).

>  Hey Ford, how did this off by one error creap in?

Like this:  the assembly code looked like:

	btst	&1,0e70000

which to my brain looks like (*C_CMND_ADDR & 2) since
(C_CMND_ADDR == 0xe70000).  It's actually looking at bit 1 of *byte 1*
(i.e., actually bit 9), because the 680x0 counts bytes backwards.  I
usually catch these as I go along, but this one slipped by (especially
since it worked anyway on my machine).  I hate Motorola byte order!
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford at kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto at cbmvax.commodore.com



More information about the Unix-pc.general mailing list