home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / blabla / filecoder / filecoder.s < prev    next >
Text File  |  1998-01-24  |  3KB  |  172 lines

  1.  
  2. ;*********************************************
  3. ;*                                           *
  4. ;* File Coder v1.01 (c)1996 by ScoTT/Inferno *
  5. ;*                                           *
  6. ;*    Program koduje pliki korzystajâc z     *
  7. ;*     funkcji logicznej exclusive or z      *
  8. ;*      parametrem podanym jako klucz        *
  9. ;*                                           *
  10. ;*********************************************
  11.  
  12. ;--------------------------- "rozprawienie sië" z parametrami
  13.     move.l    d0,d5
  14.     movea.l    a0,a5
  15.     subq.l    #1,d5
  16.     beq    usage
  17.     lea    filename,a1
  18. search:
  19.     cmp.b    #$20,(a5)
  20.     beq    space
  21.     cmp.b    #$0a,(a5)
  22.     beq    usage
  23.     move.b    (a5)+,(a1)+
  24.     bra    search
  25. space:    clr.b    0(a1)
  26.     lea    key,a1
  27.     move.b    (a5)+,(a1)
  28.     cmp.b    #$0a,(a5)
  29.     beq    usage
  30.     cmp.b    #$0a,1(a5)
  31.     beq    usage
  32.     cmp.b    #$0a,2(a5)
  33.     beq    usage
  34.     cmp.b    #$0a,3(a5)
  35.     beq    usage
  36.     move.l    (a5),key
  37.  
  38.     move.l    key,d0
  39.     not.l    d0
  40.     swap.w    d0
  41.     move.l    d0,key
  42.  
  43. ;--------------------------- otwieramy dos.library
  44.     move.l    4,a6
  45.     lea    dosname(pc),a1
  46.     clr.l    d0
  47.     jsr    -552(a6)    ;OpenLibrary
  48.     tst.l    d0
  49.     beq    byebye
  50.     move.l    d0,dosbase
  51.  
  52. ;--------------------------- otwieramy plik
  53. open_file:
  54.     move.l    d0,a6
  55.     move.l    #filename,d1
  56.     move.l    #$3ed,d2
  57.     jsr    -30(a6)    
  58.     tst.l    d0
  59.     beq    byebye
  60.     move.l    d0,filehandle
  61.  
  62. ;--------------------------- jaki dîugi plik
  63.     move.l    d0,d1
  64.     clr.l    d2
  65.     moveq.l    #1,d3        ;offset_end
  66.     jsr    -66(a6)        ;Seek
  67.     move.l    filehandle,d1
  68.     clr.l    d2
  69.     moveq.l    #-1,d3        ;offset_beginning
  70.     jsr    -66(a6)        ;Seek - przesuniëcie wskaúnika zbioru
  71.                 ;z powrotem z koïca na poczâtek zbioru
  72.     move.l    d0,file_length    ;w d0 dîugoôê zbioru w bajtach
  73.  
  74. ;--------------------------- alokacja pamiëci
  75.     move.l    4,a6
  76.     move.l    #$10001,d1
  77.     jsr    -198(a6)
  78.     tst.l    d0
  79.     beq    close_file
  80.     move.l    d0,membase
  81.  
  82. ;--------------------------- wczytanie pliku
  83.     move.l    filehandle,d1
  84.     move.l    membase,d2
  85.     move.l    file_length,d3
  86.     move.l    dosbase,a6
  87.     jsr    -42(a6)        ;read
  88.     tst.l    d0
  89.     beq    close_file
  90.  
  91. ;--------------------------- no to kodujemy
  92.     move.l    membase,a1
  93.     move.l    file_length,d1
  94.     lsr.l    #2,d1
  95.     move.l    key,d2
  96. petla:
  97.     eor.l    d2,(a1)+
  98.     dbf    d1,petla      
  99.  
  100. ;--------------------------- zapisujemy plik
  101.     move.l    filehandle,d1
  102.     clr.l    d2
  103.     moveq.l    #-1,d3
  104.     jsr    -66(a6)        ;Seek
  105.  
  106.     move.l    filehandle,d1
  107.     move.l    membase,d2
  108.     move.l    file_length,d3
  109.     jsr    -48(a6)        ;Write
  110.  
  111. ;--------------------------- zamykamy go
  112. close_file:
  113.     move.l    dosbase,a6
  114.     move.l    filehandle,d1
  115.     jsr    -36(a6)
  116.  
  117. ;--------------------------- zwalniamy pamiëê
  118. free_mem:
  119.     move.l    4,a6        ;execbase
  120.     move.l    membase,a1
  121.     move.l    file_length,d0
  122.     jsr    -210(a6)
  123.     clr.l    d0
  124.     bra    close_lib
  125.  
  126. ;--------------------------- okienko z "instrukcjâ"
  127. usage:
  128.     move.l    4,a6
  129.     lea    dosname(pc),a1
  130.     clr.l    d0
  131.     jsr    -552(a6)    ;OpenLibrary
  132.     tst.l    d0
  133.     beq    byebye
  134.     move.l    d0,dosbase
  135.     move.l    dosbase,a6
  136.     
  137.     jsr    -60(a6)
  138.     move.l    d0,windowbase
  139.  
  140.     move.l    #stext,d2    ;druk tekstu
  141.     move.l    #etext-stext,d3
  142.     move.l    dosbase,a6
  143.     move.l    windowbase,d1
  144.     jsr    -48(a6)
  145. ;--------------------------- zamykamy dos.library
  146. close_lib:
  147.     move.l      4,a6
  148.     move.l    dosbase,a1
  149.     move.l    4,a6
  150.     jsr    -414(a6)    ;CloseLibrary
  151.  
  152. byebye: 
  153.     clr.l    d0
  154.     rts
  155.  
  156. filename:    blk.b    200
  157. dosname:    dc.b    'dos.library',0
  158.     even
  159. dosbase:    dc.l    0
  160. filehandle:    dc.l    0
  161. file_length    dc.l    0
  162. membase:    dc.l    0
  163. key:        dc.l    0
  164.  
  165. windowbase:    dc.l 0
  166. stext:        dc.b    $0A
  167.         dc.b    $0a,$1b,'[33mFileCoder 1.01',$1b,'[0m (c) 1996 by ScoTT/Inferno'
  168.         dc.b    $0A
  169.         dc.b    $0A
  170.         dc.b    'Usage: FileCoder filename 4chars-key',$0A,$0A
  171. etext:
  172.