home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1994 / 6 / 01 / mini-compiler / mini.ampk / Mini-Compiler / asm / Copy.Lib next >
Encoding:
Text File  |  1995-06-01  |  1.5 KB  |  52 lines

  1.        Idnt        _Copy
  2.        Section     _CopStr,Code
  3.        Xdef      Copy
  4.        xref      Error
  5.  
  6.     ; ---------------------------
  7.     ; 24-Jul-93
  8.     ; Copy : RTS.l ,Len, Ab, String
  9.         ; 
  10.     ;       Kopiert von Position <AB> <Len> Bytes aus dem
  11.     ;     String heraus
  12.  
  13. Copy  move.l   (sp)+,a4
  14.       clr.l    d0
  15.       move.l   (sp)+,d2          ; Anzahl Bytes
  16.       bmi.s    err         ; < 0 ist falsch
  17.       move.l   (sp)+,d3          ; Pos ab der zu Kopieren ist
  18.       bmi.s    err             ; < 0 ist falsch
  19.       move.b   (sp),d0           ; log Länge String
  20.  
  21.   ; Korrektheitstest der Argumente
  22.       Cmp.l    #255,d2           ; Anzahl > 255 ?
  23.       bgt.s    err               ; ja -> Falsch
  24.       Cmp.l    #255,d3           ; Pos > 255 ?
  25.       bgt.s    err
  26.       move.l   d0,d4         ; Länge + 1 - Ab - AnzahlBytes
  27.       addq.l   #1,d4         ; muß größer/gleich sein als
  28.       sub.l    d3,d4         ; 0
  29.       sub.l    d2,d4
  30.       bpl      ok                ; Angegebene Werte passen
  31. err   moveq.l  #3,d0
  32.       jmp      Error             ; Fehler
  33.  
  34.    ; Kopieren 
  35.  
  36. ok    move.l   a7,a0         ; Anfang String Ziel
  37.       addq.l   #1,a0
  38.       move.l   a7,a1         ; Anfang String Quelle
  39.       adda.l   d3,a1             ; Adresse Teilstring
  40.       move.b   d2,(a7)           ; Ergebnislänge sichern
  41.       Cmp.l    a1,a0         ; Ziel=Quell dann Copy(St,1,x) -> Ende
  42.       beq.s    ex1         ; Fertig
  43.       tst.w    d2                ; NullString ?
  44.       beq.s    ex1
  45.       subq.l   #1,d2         ; Wg. DBRA
  46. vorwc move.b   (a1)+,(a0)+
  47.       dbra     d2,vorwc
  48. ex1   jmp      (a4)
  49.  
  50.  
  51.        end
  52.