Question

Hi guys I'm trying to work out an AVR Instruction to machine code

LDI r22, 0x3D

LDI Rd, K 

1110 KKKK dddd KKKK 

so far I've got

1110 0011 dddd 1101 

, how can dddd be covered in 4 bits if the maximum is 15.. ?

any help would be greatly appreciated.

Was it helpful?

Solution

LDI - Load Immediate

Description: Loads an 8 bit constant directly to register 16 to 31.

To encode a value of 16-31, you only need 4 bits (3-0) if you assume bit 4 to always be 1.

In your case, the encoding would be;

1110 0011 0110 1101 (where dddd is 6 since 16 + 6 = 22)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top