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. Loading a 16-bit timer value has to be done one byte at a time on the 8051.

    And yes, it should be #-2000.

    HIGH works, but LOW produces the same, incorrect, result.

    mov TL0, #LOW(-2000)

    should set TL0 to 0x30, but instead it's set to 0x05.

Reply
  • Actually it does make sense to cram -2000 into TL registers. Loading a 16-bit timer value has to be done one byte at a time on the 8051.

    And yes, it should be #-2000.

    HIGH works, but LOW produces the same, incorrect, result.

    mov TL0, #LOW(-2000)

    should set TL0 to 0x30, but instead it's set to 0x05.

Children