[Icc-mot] GNU to ICC
Edward Karpicz
ekarpicz at freemail.lt
Tue Feb 19 01:12:30 PST 2008
Oskar Atkinson wrote:
> Hi folks,
>
> My project of porting a app compile with GNU to ICC was on hold for a
> while, but now I finally need to tackle it ..
>
> With the info I go here - Thanks Edward - I am able to compile most of
> the files.
>
> First, what would be the recommended reading/newsgroup/website for
> someone who developning biz software for windows and has no idea about
> microprocessor proamming yet
>
>
> In the moment still a lot of questions open:
>
> The chip is a MC9S12C64MFA - which target device configuration
> shoul I select ?
>
I see no template for C64. Maybe use custom config.
> In the app, a ot of constants are forced ito several custom ( non
> standard ? ) memory locations.
How much space do you need for your constants? Could your constants and all
the code into 48k? It would be the best for you, just use nonpaged
0x4000.0xFFFF area. Another easy option is <<32k for constants in nonpaged
0x4000.0x7FFF:0xC000.0xFFFF, enable paged memory 0xF0000.0xF7FFF, and all
functions paged by default. Close to 32k and more than 32k for constants is
tricky.
> Does the -b linker option work to specify multiple areas?
> Here is a snippet form the GNU makefile
>
> --change-section-lma .lookup=0x3Ca400
> --change-section-lma .text3c=0x3C8000
> --change-section-lma .text3d=0x3D8000
> --change-section-lma .text3b=0x3B8000
>
> Or leave the whole stuff alone and let the linker do his job?
>
Of course it's the easiest to let linker manage it.
>
> Then, I still have trouble with some of the inline asm code
>
> Number one:
>
> __asm__ __volatile__ (
> // "ldx %1\n"
> "ldab %2,x\n"
> "clra\n"
> "ldy %3\n"
> "emul\n"
> "ldx #100\n"
> "ediv\n"
> "tfr y,d\n"
> "addd %4\n"
> : "=d"(tmp3)
> : "x"(ATD0DR5),
> "m"(egofactor_table[0]),
> "m"(flash4.egomult),
> "m"(flash4.ego0)
> : "y" );
>
> My try: ( maybe should say guess .. )
>
> asm(
> "ldx ATD0DR5\n"
ATD0DR5 is preprocessor define. It works for C, but inline asm doesn't
see it. You should use either an absolute address of ATD0DR5 or define
ATD0DR5 as
"ATD0DR5 = abs_address_of_ATD0DR5_here\n"
> "ldab egofactor_table[0],x\n"
> \\ error: invalid character '[', if I am
ICC asm doesn't work with array elements and struct offsets. 0-th
element of egofactor_table is just an egofactor_table. Also all (static)
variables are underscoped. So you write:
"ldab _egofactor_table, x\n"
Above won't work if egofactor_table is not static but stack local variable.
'%' inline asm operator comes to help. It will work with all variables, but
there are some limitations. So the best variant would be
"ldab %egofactor_table, x\n"
, if not weird ",x" at the end. It doesn't make sense. Maybe I'm not
understanding GCC asm, but what I see in your number one code is :
Load X with contents of ATD0DR5, then load egofactor_table[0] relative to
the value in ATD0DR5???? Something not right here. Was this code buggy?
> using a ptr to egofactor_table, I am getting illegal addressing mode
What do you mean by using ptr to egofactor_table? "ldab
&egofactor_table, x\n" ? It doesn't work.
> \\ the GNU sytax for ldap seems to be
> different -
> "clra\n"
> "ldy flash4.egomult\n"
You can't access struct members this way. You should know member offset
within struct. Say ptrdiff from &flash4 to &flash4.egomult is 3. Then you
would write
"ldy 3+%flash4\n"
> "emul\n"
> "ldx #100\n"
> "ediv\n"
> "tfr y,d\n"
> "addd flash4.ego0\n"
"addd <egooffset>+%flash4 \n"
> "std tmp3\n"
"std %tmp3"
> );
>
>
>
> Number two:
>
> /*
> __asm__ __volatile__ (
> "clra\n"
> "ldab %1\n"
> "tfr d,x\n"
> "dex\n"
> "ldab %2,x\n"
> "stab %0\n"
> : "=m" (t1)
> : "m" (rtsci), "m" (txbuf) );
> */
> asm(
> "clra\n"
> "ldab rtsci\n"
ldab %rtsci
> "tfr d,x\n"
> "dex\n"
> "ldab txbuf, x\n" // illegal addressing mode
V6 assembler should be able to compile it. V7 asm doesn't like it.
> "stab t1\n"
> );
>
This code should work around do the same
"ldx #_txbuf-1 \n"
"ldab %rtsci\n"
"ldab b,x\n"
"stab %t1\n"
> Thanks for any hints
What about redoing all the code from scratch :-) ?
Edward
>
> Oskar
>
> _______________________________________________
> Icc-mot mailing list
> Icc-mot at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-mot
>
More information about the Icc-mot
mailing list