File:  [Atari MiNT] / MiNT / src / asm / quickmov.s
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:55:36 2018 UTC (8 years, 1 month ago) by root
Branches: mint, MAIN
CVS tags: mint095, HEAD
MiNT 0.95 pl13

;

; quickmove(char *dst, char *src, long nbytes):

; quickly copy "nbytes" bytes from src to dst. Assumes that both

; src and dst are word aligned.

;

	SECTION TEXT



	XDEF	_quickmove



_quickmove:

	move.l	4(sp),a0		; get dst

	move.l	8(sp),a1		; get src

	move.l	12(sp),d0		; get nbytes

	lsr.l	#8,d0			; 

	lsr.l	#1,d0			; d0 = nbytes / 512

	subq.l	#1,d0			; prepare for dbra loop

	bmi	Leftover		; if < 0, skip

	movem.l	d1-d7/a2-a6,-(sp)	; save regs

L1:

	movem.l	(a1)+,d1-d7/a2-a6	; read 12*4 = 48 bytes

	movem.l	d1-d7/a2-a6,(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 2nd read

	movem.l	d1-d7/a2-a6,48(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 3rd read

	movem.l	d1-d7/a2-a6,96(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 4th read

	movem.l	d1-d7/a2-a6,144(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 5th

	movem.l	d1-d7/a2-a6,192(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 6th

	movem.l	d1-d7/a2-a6,240(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 7th

	movem.l	d1-d7/a2-a6,288(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 8th

	movem.l	d1-d7/a2-a6,336(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 9th

	movem.l	d1-d7/a2-a6,384(a0)	;

	movem.l	(a1)+,d1-d7/a2-a6	; 10th

	movem.l	d1-d7/a2-a6,432(a0)	; At this point, 480 bytes done

	movem.l	(a1)+,d1-d7/a2		; Only do 32 more bytes

	movem.l	d1-d7/a2,480(a0)	; for a total of 512



	lea	512(a0),a0

	subq.l	#1,d0

	bge.s	L1



	movem.l	(sp)+,d1-d7/a2-a6	; pop registers



Leftover:				; do the remaining bytes

	move.l	12(sp),d1

	and.l	#$01ff,d1		; d1 = nbytes % 512

	subq.l	#1,d1			; prepare for dbra loop

	bmi.s	Ldone

L2:

	move.b	(a1)+,(a0)+

	dbra	d1,L2

Ldone:

	rts				; return

	END


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.