;
;	Name: string.s
;
;	Date: Sun Sep 29 10:57:57 1996
;
;	Copy one string to another (control terminated)
;

to_r		RN 0
from_r		RN 1

counter_r	RN 2
byte_r		RN 3

		AREA |C$$code|, CODE, READONLY

		EXPORT |string_copy|

|string_copy|

; Store counter_r and byte_r on the stack as we use this

		STMFD sp!,{counter_r,byte_r}

; Copy the string

		MOV counter_r,#0		; Set counter to 0

1		LDRB byte_r,[from_r,counter_r]	; Get byte to store

		CMP byte_r,#32			; Is this the end of string ?

		STRGEB byte_r,[to_r,counter_r]	; Store the byte of not
		ADDGE counter_r,counter_r,#1	; Increase offset

		BGE %a1				; Next character

		MOV byte_r,#0			; Terminate string for C
		STRB byte_r,[to_r,counter_r]

		MOV r0,counter_r		; Return number of bytes copied + 1

		LDMFD sp!,{counter_r,byte_r}	; Get values off stack

		MOV pc,lr			; Return

		END
