[comp.sys.ibm.pc.hardware] NUMLOCK key and Extended Keyboard Scancodes .. HELP!

rfrost@spam.ua.oz.au (Richard Frost) (01/31/91)

What scan codes do the extended keyboard keys output when the NUMLOCK
is 'ON' and when the NUMLOCK key is 'OFF' ?  Are these different?

If the scan codes are not different, how is it that it is possible to 
get numerals output from the extended keys when the NUMLOCK status is
out of sequence with the computer by unplugging the keyboard?

What good technical reference material is there on such topics?

If anyone has a text file describing IBM keyboards in detail, please
email it to me.

Thanks.
--
.---------------.------------------------------.-------------------------.
| Richard Frost | USENET: rfrost@spam.ua.oz.au | FIDONET:  3:680/805     |
.-------.-------^------------------------------^-------------------------|
| O F F | A NEW life awaits you in the OFF WORLD colony, the chance to   |
| WORLD | begin again in a golden land of opportunity and adventure !    |
`-------' New climates, recreational facilities ...                      |
| The custom tailored genetically engineered humanoid replicant designed |
| especially for YOUR needs !!                          .... BLADERUNNER |
`------------------------------------------------------------------------'

jdb@reef.cis.ufl.edu (Brian K. W. Hook) (01/31/91)

In article <RFROST.91Jan31162200@spam.ua.oz.au> rfrost@spam.ua.oz.au (Richard Frost) writes:
>
>What scan codes do the extended keyboard keys output when the NUMLOCK
>is 'ON' and when the NUMLOCK key is 'OFF' ?  Are these different?
>
>If the scan codes are not different, how is it that it is possible to 
>get numerals output from the extended keys when the NUMLOCK status is
>out of sequence with the computer by unplugging the keyboard?
>
>What good technical reference material is there on such topics?

There are TONS of books on PC hardware programming!  There are certain books
I think just about every serious MS-DOS programmer will have at least one 
of:  
Advanced MS DOS Programming by Ray Duncan is one of them, 
PC Systems Programming by Abacus Publishing (this is pretty close to the 
	ULTIMATE reference....has examples in C, ASM, BASIC, PASCAL, covers 
	everything from video, TSRs, XMS, EMS, mouse, keyboard, graphics,
	etc. etc.
PC Programmer's Source Book (?) by ? ...contains just about every chart
	imaginable
MS-DOS Encyclopedia by Microsoft Press....gigantic compendium of information.
	Very good, thick, and expensive.

And most importantly, THE book I could not survive without:

	Peter Norton's Programmer's Guide to the PC and PS/2 by Brady Books.

	This has just about everything covered, including reading the low
	BIOS area to determine if NUM LOCK is on or off, reading scan codes,
	reading ASCII codes, etc. etc.  It doesn't cover mouse, but it gets
	real in depth about things such as DOS interrupts, BIOS interrupts,
	etc. etc.

Hope this helps,

Brian

PS About the scan codes, I believe one of the subfunctions of the keyboard
interrupt will return the ASCII code and scan code in the AX register.

cd5340@mars.njit.edu (Charlap) (02/01/91)

You have a minor misconception of keyboards.  With a PC/XT type keyboard,
each key returns the computer a code when a key is pressed, and one when
it is released (make codes and break codes).  The lock keys are just keys
like any other ones, each with its own make/break codes.  The lights are
toggled by the keyboard circuitry and have no bearing on the actual lock
status.  The codes are interpreted by software (usually in your BIOS) via 
the INT 9 (keyboard) interrupt.  The INT 9 handler converts the make/break
codes into events, and either toggles shift/lock status bits in memory, or
pushes keys into the buffer, or reboots the computer, or anything else that
is required by the keyboard handler.
    So, when you press <Num Lock>, the light is toggled, and a bit is set
in memory.  If you unplug the keyboard and re-plug it (a very bad habit
to get into), then the keyboard resets, and the lights are cleared.  The
computer doesn't know this, though, so the light now reads the opposite
of what it should.

   An AT keyboard has a 2-way communication channel with the AT.  This
means two things:  Unplugging the keyboard from an AT will crash the
system (often).  And the lights always read the true state of the lock
keys, so if software changes the lock status, the lights change.

--- David Charlap (cd5340@mars.njit.edu)