Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!bruce!monu1!vaxc!men408t From: men408t@vaxc.cc.monash.edu.au Newsgroups: comp.sys.zenith Subject: Re: Programming the keyboard port Message-ID: <40928.26d110f6@vaxc.cc.monash.edu.au> Date: 21 Aug 90 00:46:14 GMT Organization: Computer Centre, Monash University, Australia Lines: 68 Any port on an I.B.M PC (Including Zeniths) system can be BOTH written to or read from. As we all know the ports go from h'0000 to h'FFFF in practical terms only the range h'0000 to h'0400 is actually used. If you write to a port that is not capable of recieving data from the bus (i.e. a read only port) it will not respond. The converse applies accept you end up with garbage in the accumulator after the read cycle is complete. I/O can be constructed with totaly different functions on the read and write of one port. This is not a bad idea if your pushed for I/O space on a card design. NOW to the original problem of keyboards The keyboard lies between h'0060 and h'006F on the system port map The location h'0060 is a read only location for data (*** BUT ***) and I will quote this from the book of words (Logicraft Tech Ref Manual) "The output buffer is an 8-bit read only register at I/O address 60H. The keyboard controller used the output buffer to send scan code recieved from the keyboard and data bytes requested by command to the system. The output buffer should be read only when the output buffer's bit in the status register is 1" "The input buffer is an 8-bit write only register at i/o address 60H or 64H. Writing to address 60H sets a flag, that indicates a data write; writing to address 64H set a flag, indicating a command write. Data written to I/O 60H is sent to the keyboard, unless the keyboard controler is expecting a data byte following a controller command. Data should be written to the controller's input buffer only if the input buffer's full bit in the status register is equal to 0" In summary ========== * reading from 60H gives you data * writing to 60H sends data to the keyboard * reading from 64H gets you the status byte of the system keyboard controller * writing to 64H sends a command byte to the system keyboard controller So Yes you can flash the lights and change the states of caps lock key etc from software. If any one is interested enough I'll mail them the source code. Be Warned:- The Ctrl+Alt+del is actually maped to the reset bit on the keyboard controller and can be flipped by software access, this will reset the computer. This is not a very gracfull way to exit a program. Dougal Plummer Monash University Australia "If you steal from one author, it's plagiarism; if you steal from many, it's research" - Wilson Mizner