I am trying to write a program in assembly language for the stm8sf103
microcontroller.
I would like to store an immediate hexadecimal value in a ram register (such as $0), but this isn't working and i am wondering why:
stm8/
segment 'rom'
loop
ld $0,#5
jp loop
end
I get the error:
as1 : Error 54: Can't match Addressing mode ' ld $0,#5'
Use
MOV $0, #5
The instruction doesn't affect any condition flag.
From the ST8 Programming Manual, the description of MOV
is
Moves a byte of data from a source address to a destination address. Data is examined as it is moved1. The accumulator is not affected.
There are 3 addressing modes for the
MOV
instruction:
- An immediate byte to a direct memory location
- A direct memory location to another direct memory location (from $00 to $FF)
- A direct memory location to another direct memory location (from $0000 to $FFFF)
You can refer to that manual for the supported addressing modes (20 in total), so you can understand why ld $0,#5
cannot work (there is no Direct with Immediate addressing).
1 I can't understand this phrase, I believe there is a typo (it should be Data is not examined ...). The manual clearly states that no flag is affected.