Академический Документы
Профессиональный Документы
Культура Документы
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
0
0
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
0
0
0
0
1
0
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
0
1
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
0
1
0
0
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1 1 0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
1
0
1
0
1
0
1
1
0
1
0
0
0
0
1
1
1
1
0
1
0
1
0
1
0
0
0 0 1
0
0
0 1 0 1
1 0 0 0
0
0
0 1 1 0 0 1 1 0
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
0
0 0 0
1 0
1
0
0
1 1
0 0
0
0
0
0
0
0
0
1
1
0
0
1
0
1
0
1
1
1
1
0
0
0
0
1
0
1
1
1
1
0
0
0
1
0
0
0
0
1
1
0
0 1 0 0 1 0 0 0 1 0 0 0
0 1 0 0 1 1 0 1 1 0 0 0
0 1 0 0 1 1 1 1 1 0 0 0
cln
clr
cls
clt
clv
clz
com
cp
cpc
cpi
cpse
dec
eicall
eijmp
elpm R0
elpm Rd
elpm rd, Z
eor
fmul
fmuls
fmulsu
icall
ijmp
in
inc
jmp
ld Rd, x
ld Rd, X+
ld Rd, -X
ld Rd, Y
ld Rd, Y+
ld Rd, -Y
ldd Rd, Y+q
ld Rd, Z
ld Rd, Z+
ld Rd, -Z
ldd Rd, Z+q
ldi
lds
lpm R0, Z
lpm Rd, Z
lpm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seems that the CLR and EOR instructions have identical opcodes. When
we go check the datasheet, we see that CLR uses a 5 bit register
address, but there are 10 bits to be filled in. The EOR on the other
hand, needs two groups of 5 bits:
eor
: 0 0 1 0 0 1 r d d d d d r r r r
Rx, Rx
Rx
Apparently you just need to know this, since without this knowledge, you
cannot compose the 10 bit register address of the CLR instruction.
Another strange example:
add
lsl
: 0 0 0 0 1 1
: 0 0 0 0 1 1
It turns out, that the LSL (Logical Shift Left) is composed of an 'ADD
Rx, Rx' instruction. Which is a bit of a disappointment since shifting
is considered more efficient than adding. So take care with building the
opcodes for the LSL instruction since it needs two times the same (but
: 0 0 0 1 1 1
: 0 0 0 1 1 1
Yet another trick. ROL shifts left the involved number and then copies
the Carry flag into the LSB. Which, if you think of it carefully, is
identical to
ADC
Rx, Rx
: 0 0 1 0 0 0
: 0 0 1 0 0 0
:
:
:
:
0
0
0
0
1
1
1
1
1
1
1
1
0
0
1
1
: 1 0 0 1 0 1 0 0 0
1 0 0 0
: 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0
The bset (Bit SET in status register) instruction can set bits in the
flags register. It has a three bit hole in the third nibble from the
left. The 8 bits of the flags register are addressed as follows:
I
T
H
S
V
N
Z
C
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
so if we insert the code for the Carry flag in the Bset mnemonic we get
:
:
:
:
:
:
:
:
:
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
:
:
:
:
:
:
:
:
:
:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
: 1 1 1 1 0 1
: 1 1 1 1 0 1
: 1 1 1 1 0 1
0 0 0
0 0 0
Here we have the brcc (BRanch on Carryflag Cleared) versus the brsh
(BRanch if Same or Higher).
Another example:
ldd
ld
Rd, Z + q
Rd, Z
: 1 0 d 0 d d 0
: 1 0 0 0 0 0 0
0 d d d
0 0 0 0
I entered the encoding of the displacement 'q' with the letters 'd' in
the ldd instruction. It is totally obvious that the ld instruction is
just a special case of the ldd.
And one last one, that slipped my inspection in the first place:
ldi
ser
: 1 1 1 0
: 1 1 1 0 1 1 1 1
1 1 1 1
ldi is short for LoaD Immediate and ser is SEt all bits in Register. So,
ser loads the value FF into the register. See something funny here? The
ser is a special case of the ldi instruction. Ser is ldi with the FF
built-in...
Conclusions
There are quite some doubled instructions in the AVR instruction set. It
can be nice to have two ways of writing for the same opcode, but it may
also be confusing, since without a breakdown of the instructionset it is
not very logical to assume that two (sometimes rather) diverse mnemonics
do exactly the same.
Page created on 5 September 2006 and last revised on 01/05/2008 19:31:33
This page located at http://verhoeven272.nl/fruttenboel/AVR/opcodes.html