1 year ago

#175168

test-img

Idunnoanymore

What's the correct way to implement a sparse lookup table in 8051 assembly? (Keys have 2 bits set, 1 per nibble)

I am programming an 8052 microcontroller, and need a procedure that converts the following 8-bit input into an arbitrary set of 8-bit outputs.

All 16 possible input values are of the form 0xHL, where H and L are either 1, 2, 4, or 8.

The 16 output values are more or less arbitrary, so I shan't list them here.

I am struggling to find the "correct" way to implement this function. My instinct is to make a lookup table in code memory, but these 16 inputs are so far apart from each other, that there would be a lot of unnecessarily wasted code memory. For example, if I defined some TABLE_START: section in my code, there would be one entry at location #TABLE_START + 0x01, and another entry all the way at #TABLE_START + 0x88. That's over 100 bytes of memory for 16 entries!

Is there a better way of doing this?

assembly

lookup

lookup-tables

8051

0 Answers

Your Answer

Accepted video resources