       Idnt    	_Copy
       Section 	_CopStr,Code
       Xdef  	Copy
       xref  	Error

	; ---------------------------
	; 24-Jul-93
	; Copy : RTS.l ,Len, Ab, String
        ; 
	;       Kopiert von Position <AB> <Len> Bytes aus dem
	; 	String heraus

Copy  move.l   (sp)+,a4
      clr.l    d0
      move.l   (sp)+,d2          ; Anzahl Bytes
      bmi.s    err		 ; < 0 ist falsch
      move.l   (sp)+,d3          ; Pos ab der zu Kopieren ist
      bmi.s    err	         ; < 0 ist falsch
      move.b   (sp),d0           ; log Länge String

  ; Korrektheitstest der Argumente
      Cmp.l    #255,d2           ; Anzahl > 255 ?
      bgt.s    err               ; ja -> Falsch
      Cmp.l    #255,d3           ; Pos > 255 ?
      bgt.s    err
      move.l   d0,d4		 ; Länge + 1 - Ab - AnzahlBytes
      addq.l   #1,d4		 ; muß größer/gleich sein als
      sub.l    d3,d4		 ; 0
      sub.l    d2,d4
      bpl      ok                ; Angegebene Werte passen
err   moveq.l  #3,d0
      jmp      Error             ; Fehler

   ; Kopieren 

ok    move.l   a7,a0		 ; Anfang String Ziel
      addq.l   #1,a0
      move.l   a7,a1		 ; Anfang String Quelle
      adda.l   d3,a1             ; Adresse Teilstring
      move.b   d2,(a7)           ; Ergebnislänge sichern
      Cmp.l    a1,a0		 ; Ziel=Quell dann Copy(St,1,x) -> Ende
      beq.s    ex1		 ; Fertig
      tst.w    d2                ; NullString ?
      beq.s    ex1
      subq.l   #1,d2		 ; Wg. DBRA
vorwc move.b   (a1)+,(a0)+
      dbra     d2,vorwc
ex1   jmp      (a4)


       end
