home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / ACAUG1.DMS / in.adf / AmigaGuide.lzx / ASSEMBLER_COVERDISK_CODE / fib1.s < prev    next >
Encoding:
Text File  |  1996-04-05  |  2.6 KB  |  123 lines

  1. * --------------------------------------------------------------------
  2. * Example fib1.s
  3. * --------------------------------------------------------------------
  4. ; some system include files...
  5.    
  6.          include exec/libraries.i
  7.          include exec/exec_lib.i
  8.          include dos/dos.i
  9.          include dos/dos_lib.i
  10.              
  11. * --------------------------------------------------------------------    
  12.  
  13. CALLSYS  MACRO
  14.  
  15.          LINKLIB _LVO\1,\2
  16.     
  17.          ENDM
  18.  
  19. * --------------------------------------------------------------------    
  20.  
  21. ; EQUate definitions...
  22.  
  23. _AbsExecBase EQU    4
  24.  
  25. LF           EQU   10
  26.  
  27. NULL         EQU    0
  28.  
  29. * --------------------------------------------------------------------
  30. ; main program code...
  31.  
  32. _main     movem.l    d2,-(sp)               preserve registers
  33.  
  34.          move.l       _AbsExecBase,_SysBase      set up SysBase variable                   
  35.  
  36.      subq.l        #1,d0
  37.  
  38.          lea        buffer,a1           program's filename buffer         
  39.  
  40. .loop    move.b        (a0)+,(a1)+           copy bytes
  41.          
  42.          dbra        d0,.loop
  43.  
  44.      subq.l        #1,a1               back to command line LF
  45.      
  46.      move.b        #NULL,(a1)           replace with NULL
  47.  
  48.          lea          dos_name,a1                library name start in a1
  49.          
  50.          moveq        #0,d0                      any version will do
  51.     
  52.          CALLSYS      OpenLibrary,_SysBase       
  53.     
  54.          move.l       d0,_DOSBase                store library base
  55.  
  56.          beq          EXIT                       check result
  57.  
  58.  
  59.      move.l        #buffer,d1           filename
  60.                         
  61.      moveq          #ACCESS_READ,d2        
  62.      
  63.      CALLSYS    Lock,_DOSBase
  64.  
  65.      move.l        d0,filelock_p           BPTR pointer!
  66.           
  67.      beq.s        CLOSEDOS     
  68.  
  69.  
  70.      move.l        d0,d1               filelock_p
  71.      
  72.      move.l        #FIB,d2               address of file info block      
  73.      
  74.      CALLSYS    Examine,_DOSBase
  75.  
  76.  
  77.      move.l        filelock_p,d1
  78.      
  79.      CALLSYS    UnLock,_DOSBase
  80.  
  81.      
  82.      lea        FIB,a0
  83.      
  84.      move.l     fib_Protection(a0),d2
  85.      
  86.      bchg.l        #FIBB_DELETE,d2
  87.      
  88.      move.l        #buffer,d1           filename
  89.  
  90.      CALLSYS    SetProtection,_DOSBase
  91.  
  92.  
  93. CLOSEDOS move.l       _DOSBase,a1                base needed in a1        
  94.     
  95.          CALLSYS      CloseLibrary,_SysBase
  96.     
  97.  
  98. EXIT       movem.l    (sp)+,d2               restore registers
  99.      
  100.           clr.l         d0
  101.  
  102.          rts                                       logical end of program
  103.         
  104. * --------------------------------------------------------------------    
  105. ; variables and static data...
  106.  
  107. filelock_p      ds.l    1
  108.  
  109. _SysBase          ds.l    1
  110.  
  111. _DOSBase          ds.l    1
  112.  
  113. buffer          ds.b    100
  114.     
  115. dos_name          dc.b 'dos.library',NULL
  116.  
  117.     cnop 0,4
  118.  
  119. FIB          ds.b fib_SIZEOF
  120.  
  121. * --------------------------------------------------------------------
  122.  
  123.