GP32 Compiling Kbdrv.c (ericson Chatboard) -> Asm Error


_tyrell_

Member
Joined
May 3, 2003
Messages
159
Location
Belgium
Website
www.speccyal.be
Hi!

In order to add support for the Ericson chatboard in Speccyal K, I have tried to compile the kbdrv.c (Mr Spiv) example. My compiler configuration is devkit advance (gcc 3.0.2).

It cannot compile the 2 following functions, there's a syntax error.

void installIRQ( int num, void (*irq)(void) ) {
asm volatile(""
"stmdb sp!,{lr} \n"
"mov r0,%[_num] \n"
"mov r1,%[_irq] \n"
"swi #0x09 \n"
"ldmia sp!,{lr}"
:
: [_num] "r"(num), [_irq] "r"(irq)
: "r0","r1");
}
static void removeIRQ( int num ) {
asm volatile(""
"stmdb sp!,{lr} \n"
"mov r0,%[_num] \n"
"swi #0x0a \n"
"ldmia sp!,{lr}"
:
: [_num] "r"(num)
: "r0");
}

The error message :

D:\devkitadv\projects\speccyalk>make
d:/devkitadv/bin/arm-agb-elf-gcc -DLITTLE_ENDIAN -DGP32 -DLSB_FIRST -mcpu=arm9td
mi -mtune=arm9tdmi -fexpensive-optimizations -mapcs -O3 -mstructure-size-boundar
y=8 -mno-thumb-interwork -fno-builtin -fno-common -fno-exceptions -finline-funct
ions -fomit-frame-pointer -fshort-enums -ffast-math -fshort-double -fallow-singl
e-precision -ffreestanding -Id:/devkitadv/arm-agb-elf/include/gp32 -Id:/devkitad
v/arm-agb-elf/include -c kbdrv.c
kbdrv.c: In function `installIRQ':
kbdrv.c:52: parse error before '[' token
kbdrv.c: In function `removeIRQ':
kbdrv.c:67: parse error before '[' token
make: *** [kbdrv.o] Error 1

line 52 is : [_num] "r"(num), [_irq] "r"(irq)
line 67 is : [_num] "r"(num)

Thanks for telling me what I have to change in order to compile it (my gcc asm knowledge is too poor for that!).

_tyrell_
 
Its biult using register aliasing, which is part of gcc 3.1 or so I think.

What you can do is fix it though.. its an easy hack to alter it to not use register aliasing and just use the register name. It only uses like 1 register or 2, so its eays.. just look up register aliasing in the gcc manual.

Something like.. the first alias referred ot is r0, and the next is r1. So just replace the aliases with r0 or r1, depending on order of reference or somesuch.

jeff
 
Honestly _tyrell_.. Upgrade your gcc <_< but it goes like this..

Code:
void installIRQ( int num, void (*irq)(void) ) {
  asm volatile(""
                    "stmdb sp!,{lr} \n"
                    "mov r0,%0 \n"
                    "mov r1,%1 \n"
                    "swi #0x09 \n"
                    "ldmia sp!,{lr}"
                    :
                    : "r"(num), "r"(irq)
                    : "r0","r1");
}
etc..
 
I tried to upgrade my gcc (3.2.2 I think ?) but got lots more warning and errors so I downgraded to be sure ...

Thanks anyway for your help Mr Spiv !

_tyrell_
 
Btw.. the kbdrv.c has a really stupid bug in UART Tx FIFO handling... it has been there for ages but does not show up in the driver. Sheer good luck as all sent strings are less or equal to 15 characters. I'll update the driver some day. :blink:
 
the preInitKbd() takes PCLK as the second parameter.. not your MHz.. and max PCLK is 66MHz. So depending on your clock settings the last parameter should be either 66000000 or 33000000.
 
Well, it was locking because I didn't press the "SMS" key. Silly me ;)

Now, what I have yet to do is convert the received strings to understandable chars.

_tyrell_
 
Back
Top