简体   繁体   中英

STM8SF103 Assembly - Load immediate value to ram register

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 moved 1 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM