Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!markv From: markv@kuhub.cc.ukans.edu Newsgroups: comp.sys.amiga.programmer Subject: Re: RE: Need a helping hand(ler) Message-ID: <28397.27aee571@kuhub.cc.ukans.edu> Date: 5 Feb 91 23:03:45 GMT References: <1991Feb4.143807.4658@ssd.kodak.com> Distribution: usa Organization: University of Kansas Academic Computing Services Lines: 61 > Anyway, I figured it out (All I had to do was RTFM). > > SAS C (and possible Lattice V5.0) doesn't automatically > reload A4 with the base address of your data hunk when > you enter a function (unless you ask it to with the > -y option on the compile). > When the input handler called my handler, I went > and trashed memory in its address space. The solution > was to use "-y". Global variables will be my undoing :^) You can also do with the __saveds keyword on function definition (but I've had problems with the compiler viewing __savds as mutually exclusive from __asm, __regargs and such ilk). It also supports geta4(); as a function call (which should be the first line in the func). Note that -y/__saveds/geta4() never hurt beyond the CPU cycles to perfrom the fetch. You also need to do such things when using a function as a task. You DONT need to do this for 32 bit abs data (ie __chip, __far, or -b0) since these addresses are fixed at load time and non-context dependant. > While reading the manual, I also found a way to get > rid of the assembly code needed to call my handler. > I just declared it: > > struct InputEvent * __interrupt __asm > myhandler (register __a0 struct InputEvent *ev, > register __a1 struct MemEntry *mydata[]) > { > .... > } Right, but remember that __a4 to __a7 are generally off limits because of the way the Amiga does things (a7 is SP, a6 is used for Library base on system calls, a5 is used for stack frame, and a4 is used for global data base). > NEAT! Of course, __interrupt doesn't do anything, but > maybe someday... Actually, with 5.04 and later it DOES. An __interrupt function will perform a TST.L D0 on exit (D0 is where your return() value goes) so your can code interrupts in C even when the system uses condition codes for return checking (like the VBLANK chain). Now only if SAS would support multiple register returns of different values. Psuedo variables for registers would be nice too (not to mention inline assembly...). > MRH -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~