Instruction encoding is the step from a written instruction to the bits the CPU actually stores and fetches: machine code.
For Tiny8 it's two lookups:
- The opcode for the mnemonic, as 4 bits. (STORE = 2 =
0010.) - The address, as 4 bits. (D = 13 =
1101.)
Put the opcode in the high nibble and the address in the low nibble: 0010 1101, which is 2D in hex. Since each field is exactly one hex digit, you can encode Tiny8 instructions straight into hex.
The reverse, from bits to meaning, is instruction decoding. A quick check after encoding is to decode your answer back.
On other machines the fields have other widths, so encode in binary first, then group into hex digits. For example, a 6-bit opcode and a 10-bit address don't line up with hex digits.