home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5659 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: doc.ic.ac.uk!not-for-mail
  2. From: mdf@doc.ic.ac.uk (Martin Frost)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Plugs Ins
  5. Date: 18 Mar 1996 12:15:59 -0000
  6. Organization: Dept. of Computing, Imperial College, University of London, UK.
  7. Distribution: world
  8. Message-ID: <4ijk5v$31n@oak24.doc.ic.ac.uk>
  9. References: <Pine.SOL.3.91.960307160455.27918A@sirius>
  10. Reply-To: mdf@doc.ic.ac.uk (Martin Frost)
  11. NNTP-Posting-Host: oak24.doc.ic.ac.uk
  12. X-Newsreader: mxrn 6.18-23
  13.  
  14.  
  15. In article <Pine.SOL.3.91.960307160455.27918A@sirius>, Simon Clarke <cgs1co@sirius> writes:
  16.  
  17. >I am writing a program, and would like to use Plugin code.  How do you 
  18. >load an executable Amiga file, and what, point the program counter at 
  19. >it?  (I am writing in assembler)  Someone said something about LoadSeg() 
  20.  
  21. ; d1 is pointer to filename for plugin
  22.  
  23.     movea.l    DOSBase,a6
  24.     LIB    LoadSeg
  25.     move.l    d0,Module
  26.     beq    error        ; no file
  27.     lsl.l    #2,d0
  28.     movea.l    d0,a0
  29. [set up registers/args for plugin module]
  30.     jsr    4(a0)        ; this calls the first instruction in the file
  31.  
  32. to unload the module, use
  33.  
  34.     movea.l    DOSBase,a6
  35.     move.l    Module,d1
  36.     LIB    UnLoadSeg
  37.  
  38. I recommend also passing a magic number to the module so it won't crash.
  39.  
  40. If you want a number of routines in the module, use this:
  41.  
  42.     LIB    LoadSeg
  43.     move.l    d0,Module
  44.     beq    error            ; no file
  45.     lsl.l    #2,d0
  46.     movea.l    d0,a0
  47.     cmp.l    #MagicNumber,8(a0)
  48.     bne    error            ; not a plugin
  49. [set up d0 as index into jump table, and set up args]
  50.     jsr    12(a0,d0.w)
  51.  
  52. and start your plugin module with:
  53.  
  54.     moveq    #-1,d0
  55.     rts
  56.     dc.l    MagicNumber
  57. [jump table starts here]
  58.  
  59. Martin
  60.  
  61.  
  62.     dc.l    MagicNumber
  63.