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

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

1 Expert Approved Answer
Step: 1 Unlock

The detailed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!