![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
asy777 Guest
|
Using const tables from inline asm (#asm) |
Posted: Fri Jan 19, 2007 11:04 am |
|
|
Hi,
i've the following:
...
unsigned char const table[5]={1,2,5,2,3};
...
void main(void) {
...
...
#asm
some code...
movf some_reg,W
call &table[] <-- error
#endasm
...
...
}
The quiesiton is how can I use const tables from within #asm block?
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Jan 19, 2007 11:18 am |
|
|
With a constant like this, with a lot of difficulty...
Declared like this, the 'table', is actually a complete program, which returns the selected item.
You don't say what chip?. If it is a 16 chip, then this is inherent in the hardware really. For a 18 chip, simply declare the table with a #ROM directive instead, at a fixed location, then in your assembler, a table read command can be used starting at this address.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
asy777 Guest
|
#asm |
Posted: Fri Jan 19, 2007 11:25 am |
|
|
The chip is 16F690
this is asm listing for the table:
028 100A BCF 0xa, 0
029 108A BCF 0xa, 0x1
02A 110A BCF 0xa, 0x2
02B 0782 ADDWF 0x2, F
02C 340D RETLW 0xd
02D 3401 RETLW 0x1
02E 340D RETLW 0xd
02F 3409 RETLW 0x9
030 340D RETLW 0xd
Is there any other way to achieve this?
Is there a way to define label or something that will point to the begining of the table. I've tryed label_address() but didn't work.
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
asy777 Guest
|
#asm |
Posted: Fri Jan 19, 2007 11:36 am |
|
|
I've tryed this:
#asm
code...
...
...
#endasm
ADCON=table[ScanIndex];
#asm
...code
...
#endasm
which produced the following:
...
015 300F MOVLW 0xf (other code)
016 05AD ANDWF 0x2d, F (other code)
017 0AA6 INCF 0x26, F (other code)
018 300F MOVLW 0xf (other code)
019 05A6 ANDWF 0x26, F (other code)
01A 0826 MOVF 0x26, W <-- this is ScanIndex var
01B 202A CALL 0x2a <-- the table
01C 00A1 MOVWF 0x21 <-- what is this? some local that i haven't define
01D 0821 MOVF 0x21, W <--
01E 009F MOVWF 0x1f <-- this is ok (ADCON0=...)
01F 2821 GOTO 0x21 ... other code ...
why the compiler generate such a nonsence? The optimization level is up to MAX. This is a ISR routine and is time critical. How can I work around this.
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|