This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Literal evaluation messed up

When I write the following in uVision,

mov A, -2000

I want A to contain 0x30, as -2000 is 0xF830. Instead it contains 0x05. Is there any predefined macro to be able to treat a literal as sixteen bits and extract the lower (or upper) eight bits out of it?

Thanks.

Parents
  • Actually it does make sense to cram -2000 into TL registers
    sure, but then why do you post mov a,...

    anyhow
    this

    #define NEG_VAL -2000
    #define POS_VAL 2000
    
    
               mov   a,#LOW (NEG_VAL)
               mov   a,#HIGH (NEG_VAL)
               mov   a,#LOW (-POS_VAL)
               mov   a,#HIGH (-POS_VAL)
               mov   a,#LOW (-2000)
               mov   a,#HIGH (-2000)
    

    Gives

    0092 7430            607                mov   a,#LOW (-2000)
    0094 74F8            608                mov   a,#HIGH (-2000)
    0096 7430            609                mov   a,#LOW (-2000)
    0098 74F8            610                mov   a,#HIGH (-2000)
    009A 7430            611                mov   a,#LOW (-2000)
    009C 74F8            612                mov   a,#HIGH (-2000)
    


    what is the problem? I guess that like so many others (including myself) you are periodically blind to a missing '#' Erik

Reply
  • Actually it does make sense to cram -2000 into TL registers
    sure, but then why do you post mov a,...

    anyhow
    this

    #define NEG_VAL -2000
    #define POS_VAL 2000
    
    
               mov   a,#LOW (NEG_VAL)
               mov   a,#HIGH (NEG_VAL)
               mov   a,#LOW (-POS_VAL)
               mov   a,#HIGH (-POS_VAL)
               mov   a,#LOW (-2000)
               mov   a,#HIGH (-2000)
    

    Gives

    0092 7430            607                mov   a,#LOW (-2000)
    0094 74F8            608                mov   a,#HIGH (-2000)
    0096 7430            609                mov   a,#LOW (-2000)
    0098 74F8            610                mov   a,#HIGH (-2000)
    009A 7430            611                mov   a,#LOW (-2000)
    009C 74F8            612                mov   a,#HIGH (-2000)
    


    what is the problem? I guess that like so many others (including myself) you are periodically blind to a missing '#' Erik

Children