| View previous topic :: View next topic |
| Author |
Message |
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Tue Nov 29, 2005 2:10 am |
|
|
| We are talking about literal values here, not the contents of registers. |
|
 |
Ttelmah Guest
|
|
Posted: Tue Nov 29, 2005 4:21 am |
|
|
Just put them into the register. There is nothing 'magic' at all in this.
The original poster _said_ he was talking about literal values,but had a variable of the name.
For a literal:
[code]
#define value (2560L)
//For the low byte
MOVLW (value & 255)
//for the high byte
MOVLW (value/256L)
#asm
Best Wishes |
|
 |
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Tue Nov 29, 2005 8:35 am |
|
|
Agreed, that's ok. But the problem here is loading a calculated address into W so it can be put into FSRx
eg (as in previos message)
MOVLW ee_block >> 1 |
|
 |
Ttelmah Guest
|
|
Posted: Tue Nov 29, 2005 8:54 am |
|
|
If you want to put the 'address' of a variable, into the W register inside a function, then this works:
MOVLW &(variable_name)
If you want the address of the second byte, then:
MOVLW (&(variable_name)+1)
There are literally dozens of similar constructs that work. Basically it is a hybrid of 'C', and assembler forms. I just wish it was actually 'documented'...
Best Wishes |
|
 |
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Thu Dec 01, 2005 1:32 am |
|
|
| See previous message in this thread, not all expressions work. |
|
 |
Ttelmah Guest
|
|
Posted: Thu Dec 01, 2005 4:00 am |
|
|
| bilko wrote: | | See previous message in this thread, not all expressions work. |
This is nothing to do with the assembler, but just a limitation on what can be evaluated by the preprocessor. So (for instance):
| Code: |
int16 val;
//This will evaluate
int16 val2=&val;
//This wil not
int16 val3=(&val)/2;
//Nor will this
int16 val4=(&val)>>1);
|
The preprocessor, does not handle multiplications, shifts, or divisions, on items that are not 'constants' at the first pass. Basically these operations are only available on genuine constants, and are evaluated at the first pass through the code, before other things are done. So to keep talking about this as an assembler problem, is just not the case. You can do anything in the assembler, that the C preprocessor will accept. If you want the value shifted right, then load it, and shift it yourself...
Best Wishes |
|
 |
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Thu Dec 01, 2005 10:44 am |
|
|
Well yes.
But writing some complex bit of code to do address calculations seems a bit silly if it is possible to be worked out by the assembler/preprocessor/compiler, as well as a waste of processor time, memory, my time etc etc. |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 01, 2005 12:27 pm |
|
|
| Quote: | | as well as a waste of .... my time etc etc. |
This is a user forum. CCS rarely posts here. We can tell you what
we know about the compiler, but we can't make CCS do anything to
change the compiler. |
|
 |
bilko
Joined: 17 Oct 2003 Posts: 24 Location: Dorset, UK
|
|
Posted: Thu Dec 01, 2005 1:55 pm |
|
|
Yes. This thread is going nowhere slowly.
I assume there is a system to report bugs
(you needn't answer). |
|
 |
|