home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1989 / USER1289.MSA / LISTINGS_FILECOPY.ASM < prev    next >
Assembly Source File  |  1989-09-28  |  9KB  |  216 lines

  1. *************************************************
  2. *       FILECOPY ©1987 by Anthony Sewell        *
  3. *       Assembled with GST assembler            *
  4. *       Linked with Devpac 2 linker!            *
  5. *       (c) Atari ST User                       *
  6. *************************************************
  7.         section   code          *text/code
  8.  
  9. ******************Give back memory to Gemdos***************
  10.         move.l    4(sp),a5      *get basepage addr
  11.         move.l    #400000,a6    *keep most of mem
  12.         move.l    a6,sp         *put stack at top
  13.         sub.l     a5,a6         *calc byte total
  14.         move.l    a6,-(sp)      *num of bytes
  15.         move.l    a5,-(sp)      *start of prog
  16.         clr.w     -(sp)         *dummy word
  17.         move.w    #$4a,-(sp)    *release mem
  18.         trap #1
  19.         add.l     #12,sp
  20. **********************Hide mouse/Clear screen*************
  21.           dc.w $a000            *init A-Line data table
  22.           dc.w $a00a            *call Hide Mouse          
  23.           move.l  #mess01,a6    *>N.B. This initial>
  24.           bsr     txt_out       *>message and pause>  
  25.           bsr     in            *>may be omitted.<<
  26.           move.l    #cls,a6     *VT52 Clear screen
  27.           bsr       txt_out
  28. ********************Set disc transfer buffer************
  29.           move.l    #dta,-(sp)  *Disc transf buff
  30.           move.w    #$1a,-(sp)  *Set dta code
  31.           trap #1
  32.           addq.l    #6,sp
  33. *******************Get directory***********************
  34.           move.w    #0,-(sp)            *is read/write file    
  35.           move.l    #filename,-(sp) 
  36.           move.w    #$4e,-(sp)          *Search first code
  37.           trap #1
  38.           addq.l    #8,sp
  39.           move.l    #length,a3          *point file leng buff
  40.           move.l    #dir,a5             *point dir buff
  41. getf:     move.l    dta+26,(a3)+        *store length
  42.           move.l    #dta+30,a4          *point name
  43. get1:     move.b    (a4)+,(a5)+         *move to dir
  44.           tst.b     (a4)                *end of name?
  45.           bne       get1
  46.           clr.b     (a5)+               *zero at end
  47.           move.w    #$4f,-(sp)          *Search next
  48.           trap #1                       *{ d0 returns   }
  49.           addq.l    #2,sp               *{ zero if file }
  50.           tst.l     d0                  *{  is found    }
  51.           beq       getf
  52. *******************Print directory********************
  53.           clr.w     d4          *file count
  54.           move.l    #31,d3      *row position-1
  55.           move.l    #dir,a5     *directory buff
  56. again:    addq.l    #1,d4       *inc file num.
  57.           cmp.w     #21,d4      *end of column?
  58.           blt       num
  59.           move.l    #cursm,a6   *VT52 postn curs
  60.           addq.b    #1,d3       *inc row position
  61.           move.b    d3,colm
  62.           bsr       txt_out
  63. **                 Print file number        **
  64. num:      move.l    d4,d7       *process in d7
  65.           move.l    #nbuff,a6   *point buff end
  66.           clr.b     (a6)        *zero at end
  67.           move.b    #32,-(a6)   *preceded by space   
  68. num1:     move.l    d7,d6
  69.           divu.w    #10,d6      *{quotient is in
  70.           move.w    d6,d7       *low word - remdr
  71.           swap      d6          *in high word}
  72.           addi.w    #$30,d6     *form ASCII code
  73.           move.b    d6,-(a6)    *buff grows down
  74.           cmp.w     #0,d7       *all done?
  75.           bne       num1
  76.           bsr       txt_out     *print number
  77. **               End of number print       **  
  78.           move.l    a5,a6       *get dir buff
  79.           bsr       txt_out     *print name
  80.           tst.b     (a6)        *all done?   
  81.           beq       select
  82.           move.l    a6,a5       *save dir buff
  83.           move.l    #newln,a6   *cr/lf
  84.           bsr       txt_out
  85.           bra       again
  86. **********************Select files**********************
  87. select:   move.b    #53,colm    *position
  88.           move.b    #35,colm+1
  89.           move.l    #cursm,a6   *cursor
  90.           bsr       txt_out
  91.           move.l    #mess02,a6  *print select
  92.           bsr       txt_out     *message
  93.           move.l    #pathbf,a4  *point names
  94.           move.l    #length,a3  *point bytes
  95. sel2:      clr.l     d7
  96. sel3:      bsr       in         *get digit
  97.           cmp.b     #13,d0      *return?
  98.           beq       sel4
  99.           sub.b     #$30,d0     *ASCII to Bin
  100.           mulu      #10,d7      *for place value
  101.           add.b     d0,d7       *new units
  102.           bra sel3              *get rest ofnum
  103. sel4:     tst.b     d7          *just return?
  104.           beq       selecin
  105.           move.l    #dir,a5     *point dir
  106.           move.w    d7,-(sp)    *save count
  107. sel1:     subq.b    #1,d7       *count files
  108.           beq       sel5
  109. sel6:     tst.b     (a5)+       *find zero
  110.           bne       sel6
  111.           bra       sel1
  112. sel5:     move.l    #clearln,a6 *clear line
  113.           bsr       txt_out
  114.           move.l    a5,a6
  115.           bsr       txt_out
  116.           move.l    a5,(a4)+    *name pointer
  117.           move.w    (sp)+,d5    *get count
  118.           mulu      #4,d5       *calc offset
  119.           addi.l    #length-4,d5        *form addr
  120.           move.l    d5,a6       *pointer in a6
  121.           move.l    (a6),(a3)+  *store length
  122.           bra       sel2
  123. **********************Open and Read files**********
  124. selecin:  move.l    #pathbf,a4
  125.           move.l    #length,a3
  126.           move.l    #databuff,d4
  127. lec1:     move.w    #2,-(sp)    *read/write
  128.           move.l    (a4)+,-(sp) *point name
  129.           move.w    #$3d,-(sp)  *open
  130.           trap      #1
  131.           addq.l    #8,sp       *handle is in d0
  132.           move.w    d0,-(sp)    *save it to stack
  133. **         read           ******
  134.           move.l    d4,-(sp)    *data buff
  135.           add.l     (a3),d4     *inc buff by length
  136.           move.l    (a3)+,-(sp) *bytes to read
  137.           move.w    8(sp),-(sp) *handle
  138.           move.w    #$3f,-(sp)  *read
  139.           trap      #1
  140.           add.l     #12,sp
  141. **         close                 *****
  142. **         (handle is on stack)  *****
  143.           move.w    #$3e,-(sp)  *close
  144.           trap      #1
  145.           addq.l    #4,sp
  146.           tst.l     (a4)
  147.           bne       lec1
  148. *******************Create and Write files********************
  149.           move.l    #mess03,a6
  150.           bsr       txt_out
  151.           bsr       in
  152.           move.l    #pathbf,a4
  153.           move.l    #length,a3
  154.           move.l    #databuff,d4
  155. copy:     move.w    #0,-(sp)    *read/write
  156.           move.l    (a4)+,-(sp) *point name
  157.           move.w    #$3c,-(sp)  *create
  158.           trap      #1
  159.           addq.l    #8,sp       *handle is in d0
  160.           move.w    d0,-(sp)    *save it to stack
  161. **         write                  ******
  162.           move.l    d4,-(sp)    *data buff
  163.           add.l     (a3),d4     *inc buff by length
  164.           move.l    (a3)+,-(sp) *bytes to read
  165.           move.w    8(sp),-(sp) *handle
  166.           move.w    #$40,-(sp)  *write
  167.           trap      #1
  168.           add.l     #12,sp
  169. **         close                 *****
  170. **         (handle is on stack)  *****
  171.           move.w    #$3e,-(sp)  *close
  172.           trap      #1
  173.           addq.l    #4,sp
  174.           tst.l     (a4)
  175.           bne       copy 
  176. *********************Return to desktop***********************    
  177.           move.w    #0,-(sp)
  178.           trap #1               *Warmstart/End
  179. *************************************************************
  180. **********************Subroutines****************************
  181. txt_out:  move.b    (a6)+,d5    *Get byte from buff
  182.           tst.b     d5          *0?
  183.           beq       done        *Yes?Then end
  184.           move      d5,-(sp)    *Byte onto stack
  185.           move.w    #2,-(sp)    *Print char
  186.           trap      #1
  187.           addq.l    #4,sp       *tidy stack
  188.           bra       txt_out
  189. done:     rts
  190. in:       move.w    #1,-(sp)    *get key-
  191.           trap #1                 
  192.           addq.l    #2,sp
  193.           rts
  194. *        data                   *initialised data
  195. newln:    dc.b 13,10,0
  196. cls:      dc.b 27,'E',0
  197. clearln:  dc.b 27,'l',0
  198. mess01: dc.b 27,69,'Insert source disk,then press any key',27,118,13,10,0
  199. mess02:   dc.b 'In numerical sequence, type and <RETURN> the number'
  200.           dc.b ' of each file you wish to '
  201.           dc.b 'copy. Just type <RETURN> when finished.',13,10,0
  202. mess03: dc.b 27,69,'Insert destination disk, then press any key',13,10,0
  203. cursm:    dc.b 27,89 
  204. colm:     dc.b 32,58,0
  205. filename: dc.b '*.*',0
  206. dir:      dcb.l 165,0
  207. *         cnop 0,2      *even
  208. dta:      dcb.b  45,0
  209. pathbf:   dcb.l  10,0
  210. *         bss           *block storage section
  211.           ds.b 11
  212. nbuff:    ds.b 1
  213. length:   ds.l 50
  214. databuff: ds.b 1
  215.           end
  216.