How can I add 16 bit value ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys, How can I add 16 bits value into the memory,

I have :

Code:
LedTimer  RES 2

movlw .255
movwf  LedTimer

how can I enter .300 into LedTimer ?
Is it splitted into .150 ?

Thanks
 

You can't, at least not without a 16-bit processor. It is possible to refer to it in two 8-bit locations but it gets complicated, a better solution is to use two variables, like this:

LedTimerH RES 1
LedTimerL RES 1

movlw .255
movwf LedTimerH
movlw .45
movwf LedTimerL

You can leave RES out if you like, it defaults to 1 unless you tell it otherwise.

Brian.
 

how can I reduce them ?

Code:
counter
		 Global 	counter			;Decrementing Sec's  
	 BANKSEL 	LedTimerH		;timer value
    	 movf 	    LedTimerH,w		;for every counts
    	 btfss 	    STATUS,Z
         decf   	LedTimerH,f

          BANKSEL 	LedTimerL		;timer value
    	 movf 	    LedTimerL,w		;for every counts
    	 btfss 	    STATUS,Z
         decf   	LedTimerL,f
		 return

- - - Updated - - -

can I do like this ?

Code:
Would it be like this ?
               movlw LOW .300
                movwf LedTimer
                movlw HIGH .300
                movwf LedTimer+1

counter
         Global     counter            ;Decrementing Sec's 
         BANKSEL     LedTimer        ;timer value
         movf         LedTimer,w        ;for every counts
         btfss         STATUS,Z
         decf       LedTimer,f
        
         movf         LedTimer+1,w        ;for every counts
         btfss         STATUS,Z
         decf       LedTimer+1,f
         return
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…