Skip to main content
Associate III
Nov 28, 2023 12:48 PM UTC
Solved

How to access STM8 cpu registers

Hello

How can I access STM8S CPU registers (Cosmic compiler)? When I write this "A = 0xff" (A is a processor register accumulator), then compiler writes this "#error cpstm8 main.c:17(3) A undefined". How to fix it?

    This topic has been closed for replies.
    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    Nov 28, 2023 1:38 PM UTC

    Hello,

    You need to access internal CPU registers with assembly language. You can insert asm code inside C code.

    See https://www.cosmicsoftware.com/pdf/cxstm8_pd.pdf / page 2.

    PS: this thread is the duplication of this one: https://community.st.com/t5/stm8-mcus/stm8-cpu-register-cosmic/td-p/614181

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.

    1 reply

    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    Nov 28, 2023 1:38 PM UTC

    Hello,

    You need to access internal CPU registers with assembly language. You can insert asm code inside C code.

    See https://www.cosmicsoftware.com/pdf/cxstm8_pd.pdf / page 2.

    PS: this thread is the duplication of this one: https://community.st.com/t5/stm8-mcus/stm8-cpu-register-cosmic/td-p/614181

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.