cancel
Showing results for 
Search instead for 
Did you mean: 

Issues(?) with command ADDW and SUBW on STM8S105C6

Ivan Berton
Associate II
Posted on July 03, 2018 at 08:13

Hi

I use STM8S-Discovery Board with STM8S105C6 and ST Visual Develop v4.3.10, Windows 10.

If I use command ADDW or SUBW this way:

------------------------------------------------------------------------------

Example 1

                  ldw           X,&sharp400

         ;Load 400 into X

                  addw       X,&sharp100

          ;Add direct 100 to word X

test            cpw         X,&sharp500

         ;Compare X with 500

             

      jreq         test

               ;Jump to 'test' if X=500

------------------------------------------------------------------------------

it works properly. The content X is 500.

But if I do this

------------------------------------------------------------------------------

Example 2

k                equ           $0365

        ;RAM register is called k

                  mov          k,&sharp100

       ;Move 100 into k

                  ldw           X,&sharp400

       ;Load 400 into X

                  addw        X,k

             ;Add k to word X

test            cpw         X,&sharp500

       ;Compare X with 500

             

      jreq         test

             ;Jump to 'test' if X=500

------------------------------------------------------------------------------

it doesn�t work. The content of X is not 500.

SUBW behave the same way.

According the programming manual PM004 Doc ID 13590 Rev3, page 78 and 152,

Example 2 should actually work. Issue or do I miss something?

Thanks for reply.

Ivan 

#addw #subw #stm8s105c6 #basic-arithmetic #issue
0 REPLIES 0