Question: While scanning a 4X4 keyboard, the key code read from the port is a byte with the upper nibble holding a '0' in the
While scanning a 4X4 keyboard, the key code read from the port is a byte with the upper nibble holding a '0' in the row position of the pressed key and the lower nibble holding a 0 in the column position of the key. All other bits are '1'. We want to convert this code to a key number, where: key number = 4 * row number + column number. We propose to do it by a table look up, where we set up a table in code memory of 16 single byte entries. Each entry in this table returns the row/column number when indexed by the row/column nibble in the key code. Entries for illegal combinations of bits in the key code are set to -1. Write a function in 8051 assembly language using this look up table, which will be called with A holding the 8 bit Key code. It should re- turn the key number in A if the code is a valid combination of bits. The return value should be -1 for illegal bit combinations. All registers other than A must be preserved. Your code should be clear and well commented. Code without comments or with poor commenting will incur marks penalty.
Step by Step Solution
3.43 Rating (159 Votes )
There are 3 Steps involved in it
The detailed ... View full answer
Get step-by-step solutions from verified subject matter experts
