home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / util / pplib-1.6.lha / PPlib / example.asm < prev    next >
Assembly Source File  |  1993-12-21  |  2KB  |  82 lines

  1. **********************************
  2. *                                *
  3. *   powerpacker.library  V36     *
  4. *                                *
  5. *   Release 1.6                  *
  6. *                                *
  7. *   (c) 1991-1003 Nico François  *
  8. *                                *
  9. *   example.asm                  *
  10. *                                *
  11. *   This source is public domain *
  12. *   in all respects.             *
  13. *                                *
  14. **********************************
  15.  
  16.     SECTION "PPexample",CODE
  17.  
  18.     include "exec/types.i"
  19.     include "exec/funcdef.i"
  20.     include "exec/exec_lib.i"
  21.  
  22.     include "libraries/ppbase.i"
  23.     include "libraries/powerpacker_lib.i"
  24.  
  25. Start:
  26.     move.l  ($4).w,a6
  27.     lea     PPName,a1
  28.     moveq   #0,d0
  29.     jsr     _LVOOpenLibrary(a6)     ; open powerpacker.library
  30.     tst.l   d0
  31.     beq.s   EndIt                   ; quit if not available
  32.  
  33.     move.l  d0,_PPBase              ; store in _PPBase
  34.     move.l  d0,a6
  35.  
  36.     lea     filename,a0
  37.     moveq   #DECR_POINTER,d0
  38.     moveq   #0,d1
  39.     lea     buffer,a1
  40.     lea     length,a2
  41.     move.l  #0,a3
  42.     jsr     _LVOppLoadData(a6)      ; try to load file 'testfile'
  43.     tst.l   d0
  44.     beq.s   loadok                  ; if zero everything went ok
  45.  
  46.     * ...                           ; check error code in D0 and react
  47.  
  48.     bra.s nofree
  49.  
  50. loadok:
  51.  
  52.     * ...                           ; file was loaded, so use it
  53.  
  54. freemem:
  55.     move.l  ($4).w,a6
  56.     move.l  buffer,a1
  57.     move.l  length,d0
  58.     jsr     _LVOFreeMem(a6)         ; free memory allocated by ppLoadData
  59.  
  60. nofree:
  61.     move.l  ($4).w,a6
  62.     move.l  _PPBase,a1
  63.     jsr     _LVOCloseLibrary(a6)    ; close powerpacker.library
  64. EndIt:
  65.     rts
  66.  
  67.     SECTION "data",DATA
  68.  
  69. * library base
  70. _PPBase:        dc.l 0
  71.  
  72. * strings
  73. filename:       dc.b "testfile",0
  74. PPName:         PPNAME
  75.                 cnop 0,2            ; word-align
  76.  
  77. * buffer position/length
  78. buffer:         dc.l 0
  79. length:         dc.l 0
  80.  
  81.     END
  82.