piclist 1998\04\14\071928a >
Thread: Sustraction of two 16 bit integers
www.piclist.com/techref/index.htm?key=sustraction+two
picon face BY : marcel email (remove spam text)



Tanks for the reply's on this matter
the thing is what i wand to do is more complicated
I am reading 12 bit of data from an potentiometer when it is in the
middle
it should give something like 0x0800  "hex"
when i turn left it decreases and when i turn right it increases
The maximum increment should be from 0x80 to 0xEF  and the maximum
decrement must not cross 0x00  from0x80 down to 0x00within one reading
if so i have to increment or decrement
with these maximums or less until i reach the last readout.

I hope i am more clear on what i want to do

I can get the data msb first in the registers datahi and datalo but
the LTC1286 allows also to read LSB first

Example   first readout  could be  x0800  the next  0x0880
the differents is 80 positive is bigger than 0x7F so i add 0x7Fto
previous readout
and compare again with the last readout witch can have changed in this
example
i assume not so 0x880 sub 0x87F is 0x01 witch is less than 0x7F and
i add 0x01 to the first readout and the process stops  until a new
readout
appears  to be differend .

I don't understand what is the meaning msb stored at lower adress at the

moment i am
trying simulating this in MacPic



 Storage1      equ   0x10
 Storage2      equ   0x11
 Storage3      equ   0x12
 Storage4      equ   0x13
 TmpReg1     equ   0x14
 TmpReg2     equ   0x15
 datahi           equ   0x16
 datalo           equ   0x17




  movlw         0x01         ;
  movwf        datalo       ;
  movwf        Storage1     ;
  movlw         0x80         ;
  movwf        datahi       ;
  movwf        Storage2     ;
  clrf             TmpReg1      ;
  clrf             TmpReg2      ;

start

 ; movwf       Storage1
 ; movwf       TmpReg1

  movf            datahi,W
  subwf          Storage2,W
  movwf         TmpReg2
  btfss             STATUS,Z
  decf              TmpReg1,F
  movf             datalo,W
  subwf           TmpReg1,F
 ; incf               datalo

  goto              start

As i already  sad    thanks  for all the reply's on this matter


Marcel   Electronic  Workshop Scope

Amsterdam .


ps  my email seems to to arraive sometimes

<35333903.81F21EA5@xs4all.nl> 7bit

See also: www.piclist.com/techref/index.htm?key=sustraction+two
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Sustraction of two 16 bit integers

month overview.

new search...