[comp.sys.amiga.programmer] Input handler question

briang@sdd.hp.com (Brian Gragg) (05/29/91)

Hi,  I've been trying to have an input handler call a C subroutine and it's
just not working.  The C program installs the assembly handler just fine.
I've even checked the handler by having it set the ie_Qualifier to shift so
all my keystokes get shifted to upper case, which works fine.  But if I
include a   jsr _myhandler  in the assembly routine, the system crashes.
What am I doing wrong?

I've written a short C program to call an assembly routine which calls a C
routine.  That seemed to work.  Is there something special about the
assembly routine being a handler.

The C routine is just:

struct InputEvent *myHandler( struct InputEvent *ev)
{
  return(ev);
}

The assebly routine is:
        
	
	include "exec/types.i"
        include "exec/io.i"
        include "devices/inputevent.i"
        
        CSECT TEXT

        xdef    _HandlerInterface
        xref    _myhandler

_HandlerInterface:
        LINK    A5,#-16
        move.l  A0,D0
        
        cmp.b   #IECLASS_RAWKEY,ie_Class(a0)
        bne.s   doneit
        
        MOVEM.l A0,-(A7)
        
        JSR     _myhandler

        movem.l (A7)+,A0
doneit:
        UNLK    A5
        rts

        END

I'm somewhat new to C and even newer to assembly (68000 at least).  Is
there a problem if the C program is too large?  Are my compile options
wrong?  I've tried most of them.  

The above routine only crashes the system if the bne.s doneit branch is not
taken.

PLEASE email me any ideas.  I've spent way too much time trying to get this
working!

Thanks in advance,
Brian.

-- 
-----------------------------------------------------------------------------
  Brian Gragg    briang@sdd.hp.com   hp-sdd!briang  uunet!ucsd!hp-sdd!briang
-----------------------------------------------------------------------------

GUTEST8@cc1.kuleuven.ac.be (Ives Aerts) (05/29/91)

If you are using sas/c you should use the _saveds qualifier (look up
the right syntax and explanation in you manual).
------------------------------------------------------------------------
      Ives Aerts           |          IBM definition SY-34378
GUTEST8@BLEKUL11.BITNET    |   A signature consists of sequences of
gutest8@cc1.kuleuven.ac.be | non-blank characters separated by blanks.
------------------------------------------------------------------------

bombadil@diku.dk (Kristian Nielsen) (05/29/91)

briang@sdd.hp.com (Brian Gragg) writes:


>Hi,  I've been trying to have an input handler call a C subroutine and it's
>just not working.  The C program installs the assembly handler just fine.
>I've even checked the handler by having it set the ie_Qualifier to shift so
>all my keystokes get shifted to upper case, which works fine.  But if I
>include a   jsr _myhandler  in the assembly routine, the system crashes.
>What am I doing wrong?

  You need to reload the base pointer A4 (-y on compile or __saveds /
getA4()). And you need to disable stack checking (with the -v option). The
latter is probably the most likely source of error, since your handler
doesn't use any global varibles.

	- Kristian.