简体   繁体   English

STM8SF103汇编-将立即值加载到RAM寄存器

[英]STM8SF103 Assembly - Load immediate value to ram register

I am trying to write a program in assembly language for the stm8sf103 microcontroller. 我正在尝试用汇编语言为stm8sf103微控制器编写程序。 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: 我想将一个立即数十六进制值存储在ram寄存器中(例如$ 0),但这不起作用,我想知道为什么:

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 ST8编程手册中MOV的描述为

Moves a byte of data from a source address to a destination address. 将数据字节从源地址移动到目标地址。 Data is examined as it is moved 1 . 数据在移动时会被检查1 The accumulator is not affected. 累加器不受影响。

There are 3 addressing modes for the MOV instruction: MOV指令有3种寻址模式:

  • An immediate byte to a direct memory location 立即字节到直接存储位置
  • A direct memory location to another direct memory location (from $00 to $FF) 直接存储位置到另一个直接存储位置(从$ 00到$ FF)
  • A direct memory location to another direct memory location (from $0000 to $FFFF) 直接存储位置到另一个直接存储位置(从$ 0000到$ 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). 您可以参考该手册以了解受支持的寻址模式(总共20种),因此您可以理解为什么ld $0,#5无法工作(没有直接寻址和直接寻址)。


1 I can't understand this phrase, I believe there is a typo (it should be Data is not examined ... ). 1我听不懂这句话,我相信有一个错字(应该是未检查数据... )。 The manual clearly states that no flag is affected. 该手册明确指出没有标志受到影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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