replacing rts with rte for interrupt routine

replacing rts with rte for interrupt routine

Post by Dan » Wed, 11 Feb 2004 22:21:26


I am using the Ide68k compiler/asm/simulator to write code for the TPU of
the 68332. When writing in C and then compiling, the functions (when viewing
the asm code) always start with "link A6,#n" n being the level of the stack
or how many local vars are declared. The function then always ends with
"unlk A6" and rts. I want to convert a certain function into an isr. I'm
assuming all I have to do is change the rts into an rte? I have some of my
code to download at www.hampleman.com/tpu.htm . What I plan to do is write
the code in C, put it in the project file, build the project, edit the
resulting asm file, and then replace the C file with the asm file in the
project file.

Dan
 
 
 

replacing rts with rte for interrupt routine

Post by kgol » Thu, 12 Feb 2004 06:44:09

"Dan" < XXXX@XXXXX.COM > writes:

I don't know the Ide68k compiler, but the compilers I've used always
had some proprietary flag to indicate that a C function was an ISR.
Check your compiler documentation.

 
 
 

replacing rts with rte for interrupt routine

Post by sstear7 » Thu, 12 Feb 2004 08:53:12


You also have to make sure that all registers are preserved. Normal
subroutines are often permitted to destroy certain registers while
preserving others. For example on the ti89 rom routines can destroy
d0/d1/d2/a0/a1 freely but will always preserve all other registers.

A quick solution is to write an interupt handler that preserves all
registers and then calls the real handler.


Int_handler:
movem.l d0-d7/a0-a6,-(a7)
bsr REAL_HANLDER_NAME
movem.l (a7)+,d0-d7/a0-a6
rte
 
 
 

replacing rts with rte for interrupt routine

Post by me » Thu, 12 Feb 2004 15:01:03

Check if your compiler supports interrupt function type declarations.
Look for something like:
void interrupt myISRfunc (void)
....

If so, check the asm code produced by/for the above code for rts/rte
instruction generation.
If the above does not deliver the goods, do a dummy wrapper for your ISR
in asm.

// Easiest if all in the same file
asm( // syntax for inline asm varies
RealISR: bsr myISRfunc // do our stuff
rte // tidy up stack real proper-like
); // end of asm stuff

// back to C
void myISRfunc (void)
....

// Initialisation code
*MY_VEC_ADRS = RealISR; // jam ptr to our code into vector

Good luck
Jim Adamthwaite
 
 
 

replacing rts with rte for interrupt routine

Post by mojave » Sun, 15 Feb 2004 01:07:00

"UNIX admin" < XXXX@XXXXX.COM > writes:


Your code is exactly the same as the above with a slightly
different source notation.


Different systems use different registers for a stack /frame/
pointer, but as another poster notes, the stack frame used
by the hardware is hardwired (BSR/JSR, RTS/RTI/RTE).
 
 
 

replacing rts with rte for interrupt routine

Post by UNIX admi » Sun, 15 Feb 2004 01:20:45

"Samuel Nyall Stearley" < XXXX@XXXXX.COM > schrieb im Newsbeitrag



of
viewing
stack

How is this safe???

Why can't you just do

IRQRoutine: movem.l d0-a6,-(sp)
.
.
.
movem.l (sp)+,d0-a6
rte

And shouldn't one avoid referring to the stack pointer directly? Shouldn't
that be (sp) instead of a7, since I've read a long time ago that different
systems may use different A-register for the stack pointer.
 
 
 

replacing rts with rte for interrupt routine

Post by me » Sun, 15 Feb 2004 01:44:39

The use of A7 for subroutine and interrupt return address storage is
hard-designed into the 68K. Other address regs can be used to
synthesize stacks with user software, but this is a data operation
only.

I won't confuse the issue by mentioning that there are 2 A7 reg's (1
each for user mode & priveleged supervisor mode) in the 68K, nor will I
allude to the 68020+ having even more A7 regs, as this would destroy
the clarity we all strive for.

Jim Adamthwaite
 
 
 

replacing rts with rte for interrupt routine

Post by UNIX admi » Sun, 15 Feb 2004 01:58:10

"me" < XXXX@XXXXX.COM > schrieb im Newsbeitrag


Yes, yes, the infamous "link" and "unlink" instruction.


Correct. It's those things that make the MC680xx so great, though.

Personally, I have no experience programming the 68K on calculators and
embedded devices. I did all my assembler coding on Amiga.
I still think that the 68K mnemonic instruction set is the best thing since
sliced bread.
 
 
 

replacing rts with rte for interrupt routine

Post by sstear7 » Sun, 15 Feb 2004 12:56:26

> Why can't you just do

Bear in mind that the origional proposal was to do the modification by
hand to the generated assembly file. That could get tedious after
several compilations.



-Samuel
http://www.yqcomputer.com/
 
 
 

replacing rts with rte for interrupt routine

Post by mojave » Sun, 15 Feb 2004 18:13:52

"Dan" < XXXX@XXXXX.COM > writes:

Only if you want to use them or the operating environment
is using them and you need to maintain consistency with
that.
 
 
 

replacing rts with rte for interrupt routine

Post by Dan » Sun, 15 Feb 2004 23:38:45

> Bear in mind that the origional proposal was to do the modification by
What I planned to do was compile the C code once and use the assembly code
in the project file. You can usually make any changes directly to the asm
code if needed after changing the rts to rte. What I'm wondering is that if
I use the movem statements as mentioned, do I still need the link/unlk A6
statements?

Dan