0 Members and 1 Guest are viewing this topic.
LD A, (3, sp) ; load func arg to A reg; here, set carry = (A == 0)BCCM 0x5000, #3; here, set carry = (A == 1)BCCM 0x5005, #0; here, set carry = (A == 2)BCCM 0x5000, #6; here, set carry = (A == 3)BCCM 0x500F, #2; etc...
LD A, (3, sp) ; load func arg to A regsub a, #1 ; here, set carry = (A == 0)BCCM 0x5000, #3sub a, #1 ; here, set carry = (A == 1)BCCM 0x5005, #0sub a, #1 ; here, set carry = (A == 2)BCCM 0x5000, #6
MOV 0x04,W ; load xxx to accumulator (W)ADDWF PCL,F ; PC = PC + Accumulator [add accumulator (W) to the Program counter and store it to the File ( Program Counter) ]
My question how is Program Counter manipulation done in Stm8 assembly?
In general when I want to do some Boolean operation on an 8 bit micro and it is not directly supported in the instruction set and I want to avoid branching, I resort to 256 byte lookup tables. Input conditions form the index into the table. Might need 2 tables if'n you need to do something more complicated than set/clear.
I don't believe you can manipulate the program counter directly on STM8. You can only do so with jump, call, return, etc. instructions (e.g. JRA 0x20 - adds 0x20 to PC).
I can't afford the memory for a lookup table.What I'm actually doing is writing some STM8 C code that will, at run-time, generate some functions in raw assembly and shove them in RAM
is there some kind of arithmetic operation I can do that will have the effect of setting the carry flag if two values are equal, and clear the carry if they are not?