Mutually Exclusive Opcodes

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ignoring the assembler's nice trick of giving you multiple assembly instructions for a single opcode, I've found two opcodes which are mutually exclusive.

They are: STS (16 bit) and LD Z+q (LDD Z).

Their opcodes are as follows.

STS (16 bit): 1010 1kkk dddd kkkk
LD Z+q (LDD Z): 10q0 qq0d dddd 0qqq

Obviously, these two instructions don't exist on the same chip. There are two STS instructions. One titled STS the other STS (16 bit) in the instruction set datasheet. Problem is, how do I know which chips have which version if they're given the same name?

Obviously larger parts are going to have the 32 bit opcode version of STS, but I looked at the datasheet for an ATTiny and it just says 'STS'. Point is, I don't think the datasheet instruction set for individual parts will allow me to differentiate the part.

How can I determine this without assembling test code for every single chip?

-Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

danielson wrote:
They are: STS (16 bit) and LD Z+q (LDD Z).

Their opcodes are as follows.

STS (16 bit): 1010 1kkk dddd kkkk
LD Z+q (LDD Z): 10q0 qq0d dddd 0qqq

Obviously, these two instructions don't exist on the same chip. There are two STS instructions. One titled STS the other STS (16 bit) in the instruction set datasheet. Problem is, how do I know which chips have which version if they're given the same name?

Look at the number of cycles.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The chip's datasheet lists all instructions implemented in this particular chip.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

danielson wrote:
Ignoring the assembler's nice trick of giving you multiple assembly instructions for a single opcode, I've found two opcodes which are mutually exclusive.

They are: STS (16 bit) and LD Z+q (LDD Z).

Their opcodes are as follows.

STS (16 bit): 1010 1kkk dddd kkkk
LD Z+q (LDD Z): 10q0 qq0d dddd 0qqq

Obviously, these two instructions don't exist on the same chip. There are two STS instructions. One titled STS the other STS (16 bit) in the instruction set datasheet. Problem is, how do I know which chips have which version if they're given the same name?

Obviously larger parts are going to have the 32 bit opcode version of STS, but I looked at the datasheet for an ATTiny and it just says 'STS'. Point is, I don't think the datasheet instruction set for individual parts will allow me to differentiate the part.

How can I determine this without assembling test code for every single chip?

-Thanks

The STS (16-bit) and LDS (16-bit) instructions only exist in the so-called "brain dead" reduced AVR cores. Currently, this includes only the ATtiny4/5/9/10 family, and the ATtiny20/40 family.

They are "brain dead" because they also lack some features that had been common to every other 8-bit AVR that came before, most notably they lack CPU registers R0 to R15. And, as you correctly deduced, they also lack the indirect-with-displacement addressing scheme used in LDD/STD.

So, a quick rule of thumb is: Does the CPU implement registgers R0 to R15?

If not, then the 16-bit LDS/STS is used, and LDD/STD is not implemented.

If so, then the 32-bit LDS/STS is used (except for very old devices which didn't have any SRAM address space at all), and LDD/STD is implemented.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you!