View Single Post
Old August 4th, 2022, 03:39 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,608
Oh wait, I think I misunderstood the query: the problem may be whether the PLC-5 has unsigned INTs or 32-bit DINTs.

PLC-5 does have floats, so you could MOVe the INT value (e.g. I3.5 or N7:0) to an element of a float file (e.g. F8:0), and then add 65536 to it if the INT value is negative:
Code:
MOV N7:0 F8:0
XIC N7:0/15    ADD F8:0 65536.0 F8:0
Alternate, probably clearer:
Code:
MOV N7:0 F8:0
LES N7:0 0    ADD F8:0 65536.0 F8:0
Floats have 23 bits of mantissa, so there will be no loss of data.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good

Last edited by drbitboy; August 4th, 2022 at 03:43 PM.
  Reply With Quote