We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
what are you trying to do?? it makes no sense to try to cram -2000 into an 8 bit register.
however, whatever you try to do (which must make sense to you) I suggest you look up HIGH and LOW in the manusl for the solution.
btw should it not be mov A, #-2000
Erik
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.
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
It's working now. I had to move some code that _should_ have caused a memory conflict error during compilation, but didn't.
31 oct 2006, 23hrs now, 1 Nov 2006, 10:07 cst
looks like have been working overnight,
what is the progress other than a "closed" uvision window.. and not working
ya, wonder what time you get to your job or work,