Shop OBEX P1 Docs P2 Docs Learn Events
@Bean, error loading wordparameter (negative constant) — Parallax Forums

@Bean, error loading wordparameter (negative constant)

Peter VerkaikPeter Verkaik Posts: 3,956
edited 2009-03-26 17:08 in General Discussion
Bean,
I have a function

fmtString·FUNC·1,5,5,byte,word,byte,byte,byte

and use it like this:

· sStr = fmtString -128,10,@ascii,7··'value=-128, output="-128",0

This compiles into:
   823  002D  0C80        MOV __PARAM1,#-128             ;  sStr = fmtString -128,10,@ascii,7           'value=-128, output="-128",0
        002E  0028
   824  002F  0069        CLR __PARAM2                  
   825  0030  0C0A        MOV __PARAM3,#10              
        0031  002A
   826  0032  0C50        MOV __PARAM4,#ascii           
        0033  002B
   827  0034  0C07        MOV __PARAM5,#7               
        0035  002C
   828  0036  0010        CALL @__fmtString             
        0037  0908
   829  0038  0208        MOV sStr,__PARAM1             
        0039  002E

SX/B assumes incorrectly that the constant is positive and smaller than 256.
When using

· sStr = fmtString -1280,10,@ascii,7··'value=-1280, output="-1280",0

it compiles into:
   823  002D  0C00        MOV __PARAM1,#(-1280) & 255    ;  sStr = fmtString -1280,10,@ascii,7          'value=-1280, output="-1280",0
        002E  0028
   824  002F  0CFB        MOV __PARAM2,#(-1280) >> 8    
        0030  0029
   825  0031  0C0A        MOV __PARAM3,#10              
        0032  002A
   826  0033  0C50        MOV __PARAM4,#ascii           
        0034  002B
   827  0035  0C07        MOV __PARAM5,#7               
        0036  002C
   828  0037  0010        CALL @__fmtString             
        0038  0908
   829  0039  0208        MOV sStr,__PARAM1             
        003A  002E

This is correct.

The first should be:
   823  002D  0C00        MOV __PARAM1,#(-128) & 255    ;  sStr = fmtString -1280,10,@ascii,7          'value=-128, output="-128",0
        002E  0028
   824  002F  0CFB        MOV __PARAM2,#(-128) >> 8    
        0030  0029


regards peter

Post Edited (Peter Verkaik) : 3/26/2009 2:13:20 PM GMT

Comments

  • BeanBean Posts: 8,129
    edited 2009-03-26 16:46
    Peter,
    Yep, another optimization attempt that backfired...
    I'll get that fixed and post again ASAP.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • BeanBean Posts: 8,129
    edited 2009-03-26 16:57
    Okay, posted version 2.00.18 that should fix the bug with negative constants that are > -256.

    Peter, let me know if you get a chance to test it.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-03-26 17:08
    Bean,
    Seems to work now.
    Thanks.

    regards peter
Sign In or Register to comment.