cancel
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

Handling Two byte variables in assembly

Anonymous
Not applicable

Handling Two byte variables in assembly

Question: How to perform arithmetic operations on  a two bytes variable in assembly language?

 

Answer:

Since PSoC is an 8 bit MCU, there are no instructions to process 16 bit data directly. Please use carry to perform 2 byte arithmetic. Following is an example for a loop of 500 counts.

Variable Declaration:

area bss(ram)
loopCount: BLK 2

Code:

mov [loopCount+1],f4h
mov [loopCount],1 ;load 500 to loopCount

loop:
;--------------------------------------------------------
;Write your code that has to be performed within the loop
;--------------------------------------------------------

sub [loopCount+1],1  // Subtract 1 from LSB
sbb [loopCount],0     // Subtract with borrow from MSB
jnc loop

Similarly for addition, use the "add" and "adc" instructions.

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎Mar 27, 2011 05:25 AM
Updated by:
Anonymous
 
Contributors