Get the difference between two values in memory

View: New views
2 Messages — Rating Filter:   Alert me  

Get the difference between two values in memory

by Harry H. Arends :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,
 
I have managed to write this code to get the difference between two values
in RAM.
 
Pos_24:                                   ;*Move to posistion#24
          movlw     d'24'                 ;*240Green
          movwf     TARG_STAT     ; save
          movf        PRES_STAT,w ; present location
          sublw     d'24'
          movwf     DEF_STAT       ; calculate setps to move
          goto        ExitFunction
 
But can this be done easier becourse repeating this for all 24 stations
costs a lot of memory.
 
Harry
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Get the difference between two values in memory

by Olin Lathrop :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Harry H. Arends wrote:

> Pos_24:                                   ;*Move to posistion#24
>           movlw     d'24'                 ;*240Green
>           movwf     TARG_STAT     ; save
>           movf        PRES_STAT,w ; present location
>           sublw     d'24'
>           movwf     DEF_STAT       ; calculate setps to move
>           goto        ExitFunction
>
> But can this be done easier becourse repeating this for all 24
> stations costs a lot of memory.

That depends on exactly what "this" is, what you are really trying to
accomplish, how your data is layed out, etc.  If you've got a bunch of
identical things to do, a loop sounds like a obvious choice.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
LightInTheBox - Buy quality products at wholesale price!