cancel
Showing results for 
Search instead for 
Did you mean: 

BSET BRES with dynamic position

whitehorsesoft
Associate

Hello, I'm successfully using BSET and BRES assembler instructions where the position is constant. However, I'm having trouble getting it to work where the position is determined at runtime.

For example:

 

bset 0x500f, 2 ; works
ldw x, (0x03, sp)
bset 0x500f, x ; doesn't work

 

I've looked at several sites, but all seem to have constant positions.

One workaround would be to have a full list of BSET instructions, one for each position, and jump to the appropriate instruction based on a decision. This wouldn't be bad necessarily, but hoping for a better way.

 

References:

assembler instructions datasheet in PM0044, section 7 (specifically 7.4): https://www.st.com/content/ccc/resource/technical/document/programming_manual/43/24/13/9a/89/df/45/ed/CD00161709.pdf/files/CD00161709.pdf/jcr:content/translations/en.CD00161709.pdf

lujji's very helpful blog post: https://lujji.github.io/blog/mixing-c-and-assembly-on-stm8/

eforth: https://github.com/TG9541/stm8ef/wiki/STM8-eForth-Compiler-and-Assembly

a nice GitHub repo: https://github.com/search?q=repo%3Aaaw20904%2FSTM8_library%20bset&type=code

0 REPLIES 0