davidc%yak@gatech.edu (Dave Corbin) (03/05/88)
First off, where do the LVOs come from? Is there some file (I hope) with them defined? Where does one get this file? Second. I want to start do some mucking with SetFunction. I understand the principals of how to use it, but I'm not a real assembly-jock. Does anyone have a nice example(entire program) that just does one simple stupid SetFunction. ? If it is mostly in C, I'd be even happier. Thanks.
dillon@CORY.BERKELEY.EDU (Matt Dillon) (03/06/88)
>First off, where do the LVOs come from? Is there some file (I hope) with them >defined? Where does one get this file? LVOs are defined IN the link library... They are actual symbols used as offsets. I suppose you can recover them by decoding the link library. Otherwise, if you don't have access to a list you need to write a program that simply prints their values out. >Second. I want to start do some mucking with SetFunction. I understand the >principals of how to use it, but I'm not a real assembly-jock. Does anyone >have a nice example(entire program) that just does one simple stupid SetFunction. >? >If it is mostly in C, I'd be even happier. >Thanks. > SetFunction is extremely easy in itself. However, you must conform with the same calling conventions as the original functions, including preserving the proper registers and getting arguments from the proper registers. Thus, SetFunction'd code is usually written in assembly. So it depends on the function you are replacing/intercepting. -Matt
bryce@eris (Bryce Nesbitt) (03/06/88)
In article <5136@pyr.gatech.EDU> davidc%yak@gatech.edu (Dave Corbin) writes: >First off, where do the LVOs come from? Is there some file (I hope) with them >defined? Where does one get this file? The ultimate source of everything is the ".fd" files. These contains the definitions from which all others can be built. They are not *directly* useable. Lattice C V4.0 comes with the .fds, and they are also available from CATS. (Some CATS person should post the catalog of CATS offerings, BTW). The Library Vector Offsets (LVOs) are also stored in the amiga.lib library, and referenced indirectly: XREF _LVODeleteLayer move.w #_LVODeleteLayer,d0 For assembly language use, my "small.lib" is much better, since it contains *only* the LVOs and not a 70K of other junk. (See fish #72 or #92). Blink has a bug that Gurus on this file, but you can get arround this by not telling Blink that it is really a library. For getting a neat printed reference chart, look in the comp.source.amiga archives for "library_referencer". Compile it. Cd to the fd.files directory and execute it. This will show the LVO offsets in a nice, readable way. >Second. I want to start do some mucking with SetFunction. I understand the >principals of how to use it, but I'm not a real assembly-jock. Does anyone >have a nice example(entire program) that just does one simple stupid >SetFunction. >If it is mostly in C, I'd be even happier. C and SetFunction() don't mix well. You need to at least write an assebly stub for the program you are SetFunction()ing. The comp.sources.amiga archives have "Cancel!", an assembly program I wrote that uses SetFunction. (Cancel! will reboot the machine if a Guru occurs while you are gone, and Cancel any requesters that show up). |\_/| . ACK!, NAK!, EOT!, SOH! {O_o} . Bryce Nesbitt (") BIX: mleeds (temporarily) U USENET: bryce@eris.berkeley.EDU -or- ucbvax!eris!bryce
scott@applix.UUCP (Scott Evernden) (03/07/88)
In article <8803060000.AA29981@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: > >>First off, where do the LVOs come from? Is there some file (I hope) with them >>defined? Where does one get this file? > > LVOs are defined IN the link library... They are actual symbols >used as offsets. I suppose you can recover them by decoding the link >library. Otherwise, if you don't have access to a list you need to >write a program that simply prints their values out. I do it this way from Manx: =========================== extern int lvoScrollRaster; VOID myScrollRaster(); /*********************************************/ /* get the ABS symbol describing gfx/intui lib offsets */ #asm public _LVOScrollRaster dseg _lvoScrollRaster dc.w _LVOScrollRaster cseg #endasm oldScrollRaster = SetFunction(GfxBase, (long) lvoScrollRaster, myScrollRaster); -scott
schaub@sugar.UUCP (Markus Schaub) (03/17/88)
In article <7407@agate.BERKELEY.EDU>, bryce@eris (Bryce Nesbitt) writes: > C and SetFunction() don't mix well. You need to at least write an > assebly stub for the program you are SetFunction()ing. M2Amiga enables you to SetFunction without any assembly. The mechanism used to generate correct ROM calls directly by the compiler can be used here. It is basically the specification of passing parameters in registers instead of pushing them on the stack. However it is Modula-2, if you're interested in an example, let me know. -- // Markus Schaub | The Modula-2 People: // M2Amiga Developer | Interface Technologies Corp. \\ // uunet!nuchat!sugar!schaub | 3336 Richmond Ave. Suite 323 \X/ (713) 523-8422 | Houston, TX 77098
schaub@sugar.UUCP (Markus Schaub) (03/18/88)
In article <661@applix.UUCP>, scott@applix.UUCP (Scott Evernden) writes: > > VOID myScrollRaster(); > > oldScrollRaster = SetFunction(GfxBase, (long) lvoScrollRaster, > myScrollRaster); > -scott How do you access the parameters of ScrollRaster? My magic book tells me that there are 7 parameters available in 7 registers. -- // Markus Schaub | The Modula-2 People: // M2Amiga Developer | Interface Technologies Corp. \\ // uunet!nuchat!sugar!schaub | 3336 Richmond Ave. Suite 323 \X/ (713) 523-8422 | Houston, TX 77098
scott@applix.UUCP (Scott Evernden) (03/20/88)
In article <1581@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: >In article <661@applix.UUCP>, scott@applix.UUCP (Scott Evernden) writes: >> >> VOID myScrollRaster(); >> >> oldScrollRaster = SetFunction(GfxBase, (long) lvoScrollRaster, >> myScrollRaster); >> -scott > >How do you access the parameters of ScrollRaster? My magic book tells me >that there are 7 parameters available in 7 registers. This SetFunction() call allows me to *intercept* calls to ScrollRaster(). The parameters are in the registers they're supposed to be in. Perhaps I don't follow the question? Here's an sketch of some code continuing the example above (again, for Manx C): #asm public _geta4 public _myScrollRaster _myScrollRaster: ; 'scuse me move.l a4,-(sp) jsr _geta4 ; establish addressing tst.l do_i_need_to_intercept_scroll_raster beq.s 1$ movem.l a1/d0-d5,-(sp) ; save args passed to ScrollRaster() jsr _do_my_scroll_raster_thing ; perhaps accessing parms movem.l (sp)+,a1/d0-d5 ; restore passed parameters 1$: movea.l _oldScrollRaster,a0 ; the real vector movea.l (sp)+,a4 ; a4 as it was jmp (a0) ; go do the real thing #endasm -scott
shimoda@rmi.UUCP (Markus Schmidt) (03/20/88)
In article <1581@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: : : How do you access the parameters of ScrollRaster? My magic book tells me : that there are 7 parameters available in 7 registers. : -- Hi! Maybe the description for "C" may help you: ScrollRaster(rp, dx,dy, xmin,ymin, xmax,ymax) rp is the address of the Rastport to scroll xmin .. ymax is the area to scroll dx,dy is the direction to scroll (e.g. (0,-8) for one line up) Hope to have helped you Markus |._,| - - ==O== Never trust a smiling cat `-' (shimoda@rmi.uucp)
schaub@sugar.UUCP (Markus Schaub) (03/27/88)
In article <924@rmi.UUCP>, shimoda@rmi.UUCP (Markus Schmidt) writes: > In article <1581@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: > : > : How do you access the parameters of ScrollRaster? My magic book tells me > : that there are 7 parameters available in 7 registers. > > Maybe the description for "C" may help you: > ScrollRaster(rp, dx,dy, xmin,ymin, xmax,ymax) 1 2 3 4 5 6 7 hey you also know that there are 7 parameters. The question remains. How do you access the parameters if you write your replacement ScrollRaster in C. I never heard of any way of getting parameters in registers instead of having them pushed on the STACK. (In C that is, M2Amiga has that feature) Yes Peter, I'm writing a make utility for M2Amiga. I know who nice make is :-) -- // Markus Schaub | The Modula-2 People: // M2Amiga Developer | Interface Technologies Corp. \\ // uunet!nuchat!sugar!schaub | 3336 Richmond Ave. Suite 323 \X/ (713) 523-8422 | Houston, TX 77098
schaub@sugar.UUCP (Markus Schaub) (03/27/88)
In article <677@applix.UUCP>, scott@applix.UUCP (Scott Evernden) writes: > > The parameters are in the registers they're supposed to be in. Perhaps I > don't follow the question? Here's an sketch of some code continuing > the example above (again, for Manx C): ^^^^^^^^ If the code after #asm is C for you then this is the answer. For me it's assembler and the answer therefore is NO. You cannot write a replacement for a library routine in C. -- // Markus Schaub | The Modula-2 People: // M2Amiga Developer | Interface Technologies Corp. \\ // uunet!nuchat!sugar!schaub | 3336 Richmond Ave. Suite 323 \X/ (713) 523-8422 | Houston, TX 77098
dillon@CORY.BERKELEY.EDU (Matt Dillon) (03/28/88)
>If the code after #asm is C for you then this is the answer. For me it's >assembler and the answer therefore is NO. >You cannot write a replacement for a library routine in C. You can, but you need a small assembly 'hook' to move the registers onto the stack. For non-critical library calls this works fine. For critical library calls you would want to write it in assembly anyway. And, of course, if the library is designed for a C stack frame, no hook is needed (but all standard Amiga libraries pass arguments in registers). -Matt
scott@applix.UUCP (Scott Evernden) (03/29/88)
In article <1767@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: >In article <677@applix.UUCP>, scott@applix.UUCP (Scott Evernden) writes: >> >> ... Here's an sketch of some code continuing >> the example above (again, for Manx C): > ^^^^^^^^ >If the code after #asm is C for you then this is the answer. For me it's >assembler and the answer therefore is NO. >You cannot write a replacement for a library routine in C. By the same reasoning, you cannot call Amiga library routines from C. You are correct insofar as you need to write some glue code to acquire arguments to the function, but this is generally doable in about 3 instructions: #asm _myScrollRaster: movem.l a1/d0-d5,-(sp) jsr _myScrollRaster_in_C lea sp(14),sp #endif -scott
ncreed@ndsuvax.UUCP (Walter Reed) (03/29/88)
In article <1764@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: :In article <924@rmi.UUCP>, shimoda@rmi.UUCP (Markus Schmidt) writes: :> In article <1581@sugar.UUCP> schaub@sugar.UUCP (Markus Schaub) writes: :> : :> : How do you access the parameters of ScrollRaster? My magic book tells me :> : that there are 7 parameters available in 7 registers. :> :> Maybe the description for "C" may help you: :> ScrollRaster(rp, dx,dy, xmin,ymin, xmax,ymax) : 1 2 3 4 5 6 7 hey you also know that there :are 7 parameters. The question remains. How do you access the parameters if :you write your replacement ScrollRaster in C. I never heard of any way of :getting parameters in registers instead of having them pushed on the STACK. :(In C that is, M2Amiga has that feature) Lattice C 4.0 has a feature called pragma. Pragma allows the bypass of amiga.lib and accesses the rom routines directly, passing the parameters via registers instead of the stack. If you have the FD files, you could probably find a way to do this in older versions of lattice or another vendors C. (BTW, I don't have my lattice manual next to me, so I could have this a little messed up...) : : // Markus Schaub | The Modula-2 People: -- /* Walter Reed UUCP : uunet!ndsuvax!ncreed Internet : ncreed%NDSUVAX.BITNET@CUNYVM.CUNY.EDU Ph 701-235-0774 Bitnet : ncreed@ndsuvax OR NU105451@NDSUVM1 ------------------- */