IceCube
Tester - PRO for PSoC
 
Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
|
|
Hi,
I try to do this: Code:
#define SSC(function) asm("mov X,SP");asm("mov A,X");asm("add A,3");asm("mov [249],A");asm("mov [248],58");asm("mov A,_function");asm("SSC") It is obvious this does not work. I know there is a ssc intruction in psoc.h and one in m8c.inc but I like to know how to do this within the c-compiler.
Regards, Rolf
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
Rolf, I assume when you say it doesn't work, you're referring to the failure to substitute the "function" argument in the macro?
If so, that's because you need to use the (ANSI C Standard) stringization operator #, e.g.
Code:
#define SSC(function) asm("mov X,SP");\ asm("mov A,X");\ asm("add A,3");\ asm("mov [249],A");\ asm("mov [248],58");\ asm("mov A," #function );\ asm("SSC")
main() { SSC(12); }
But I recommend using the built-in __ssc() pseudo-function anyway.
Clyde
|
IceCube
Tester - PRO for PSoC
 
Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
|
|
Thank you Clyde, that is what I meant.
I am writing a UART bootloader and I want to include as less as possible.
Regards, Rolf
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
The built-in __ssc() pseudo-function produces exactly the same code you have in your macro, with the advantage that the argument can be any C expression.
|
IceCube
Tester - PRO for PSoC
 
Reged: Jun 27 2007
Posts: 86
Loc: The Netherlands
|
|
Yes Clyde, I know.
When I was looking at the flash.c source I saw something strange: Code:
if(_flash_banks != 0) FLS_PR1 = 0; // tables are in bank 0. __ssc(TableRead); and Code:
if(_flash_banks != 0) { FLS_PR1 = blockno/BLOCKS_PER_BANK; BLOCKID = blockno % BLOCKS_PER_BANK; } else BLOCKID = blockno; __ssc(EraseBlock);
Shouldn't this be: Code:
if(_flash_banks != 1) { ...
Regards, Rolf
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
Good pickup! Fortunately it's harmless, other than generating some unnecessary moves on single-bank chips.
I've updated the source, that will appear in the next build.
Clyde
|