This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: m68k attribute interrupt


Paul Andrews wrote:
> 
> Unfortunetly I have discovered a problem with your patch. If an interrupt
> routine does nothing but call a function with a constant parameter, the
> scratch registers (d0/d1/a0/a1) are not saved, however the stack pointer is
> (which seems a bit redundant anyhow). Here is a simple test case and the
> code it generates:( gcc -m68000 -O2 -fomit-frame-pointers -g )
> 
>         #define INTERRUPT __attribute__ ((interrupt))
> 
>         volatile char *p;
> 
>         void AnotherFunction( char b )
>         {
>           p = b;
>           *p = 0x00;
>         }
> 
>         void INTERRUPT TestInt( void )
>         {
>           AnotherFunction( 0xf8 );
>         }
> 
> The output from this is as follows:(using objdump)
> 
> 00000000 <AnotherFunction>:
>    0:   102f 0007       moveb %sp@(7),%d0
>    4:   4880            extw %d0
>    6:   3040            moveaw %d0,%a0
>    8:   23c8 0000 0000  movel %a0,0 <AnotherFunction>
>    e:   10bc 0000       moveb #0,%a0@
>   12:   4e75            rts
>   14:   4e71            nop
> 
> 00000016 <TestInt>:
>   16:   2f0f            movel %sp,%sp@-
>   18:   4878 fff8       pea fffffff8 <.stabstr+0xfffffe20>
>   1c:   4eb9 0000 0000  jsr 0 <AnotherFunction>
>   22:   588f            addql #4,%sp
>   24:   2e5f            moveal %sp@+,%sp
>   26:   4e73            rte
> 
> As you can see, TestInt only touches the stack pointer, so this is the only
> register saved (is this needed?) . AnotherFunction uses d0 and a0 which have
> 
> not been saved because TestInt did not know about it.
> I'm not sure what can be done about this...any ideas?

 My gcc-2.95.2 for m68k-coff (and -elf) produced the following (without '-g') :

E:\usr\local\samples\m68k>objdump -d intrbug.o

intrbug.o:     file format coff-m68k

Disassembly of section .text:

00000000 <AnotherFunction>:
   0:   102f 0007       moveb %sp@(7),%d0
   4:   4880            extw %d0
   6:   3040            moveaw %d0,%a0
   8:   23c8 0000 0000  movel %a0,0 <AnotherFunction>
   e:   10bc 0000       moveb #0,%a0@
  12:   4e75            rts
  14:   4e71            nop

00000016 <TestInt>:
  16:   48e7 c0c1       moveml %d0-%d1/%a0-%a1/%sp,%sp@-
  1a:   4878 fff8       pea fffffff8 <.data+0xffffffcc>
  1e:   4eb9 0000 0000  jsr 0 <AnotherFunction>
  24:   588f            addql #4,%sp
  26:   4cdf 8303       moveml %sp@+,%d0-%d1/%a0-%a1/%sp
  2a:   4e73            rte

 So I must have added something extra to the original patches... I will look at what
it is and send the fixes. Ok, the saving of the stack pointer must be investigated,
I'm not an expert with the m68k calling convention, but it may be necessary to save
the sp...

Cheers, Kai

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]