BINTOASCII and @ptrdec Bug ?

comp_bernd2

New Member
When using @ ptrdec in command BINTOASCII is only the first (thousands) set. The simulator is, but not in the chip. Is it a bug?


symbol w_val = w6

w_val =1234

ptr = 0

BINTOASCII w_val,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc

ptr = 10
BINTOASCII w_val,@ptrdec,@ptrdec,@ptrdec,@ptrdec,@ptrdec

Thanks Bernd
sertxd("---",13,10)

for b5 = 0 to 20

get b5 , b20

sertxd(#b5," ",#b20,13,10)

next

goto main
 

hippy

Technical Support
Staff member
BINTOASCII with @ptrdec is expanded by the compiler to ...

@ptrdec = w6 / 10000 + 48
@ptrdec = w6 / 1000 // 10 + 48
@ptrdec = w6 / 100 // 10 + 48
@ptrdec = w6 / 10 // 10 + 48
@ptrdec = w6 // 10 + 48

So there's no reason it shouldn't work in the real chip and it works okay in the simulator
 

BCJKiwi

Senior Member
Which Chip/firmware?
28X1 FW A.1 had some issues with @ptrinc - resolved in FW A.2

Code:
Bin2Asc_W:
#rem FW A.1
 bintoascii w1,b4,b5,b6,b7,b8
 @ptr =b5       '1000s (10,000s not req'd, Max value 9999)
 inc ptr
 @ptr =b6       '100s
 inc ptr
 @ptr =b7       '10s
 inc ptr
 @ptr =b8       '1s
#endrem
'FW A.2
 bintoascii w1,b4,b5,b6,b7,b8
 @ptrinc =b5      '1000s (10,000s not req'd, Max value 9999)
 @ptrinc =b6      '100s
 @ptrinc =b7      '10s
 @ptr    =b8      '1s
Return
Have not actually tried to use the @ptrinc/dec directly - only through variables - but then as can be seen from above snippet from working code - don't want to store all the data.
 

moxhamj

New Member
Hippy, thanks for that. It would explain why bintoascii gobbles up so much code space. If you only call it once, no problem, but if you use it more than once, I wonder if it may be more efficient to put it in a subroutine?
 
Top