	.include	"features.inc"
	.section	.text
	.global	put_line
	.syntax	divided
	.type	put_line, %function
put_line:
	.ifdef	NetBSD
	str	fp, [sp, #-4]!		@ Preserve FP
	.else
	stmdb	sp!, {r7, fp}		@ Preserve R7 and FP
	.endif
	mov	fp, sp
	sub	sp, sp, #12		@ Allocate space
	sub	r2, r1, #4
	ldr	r2, [r2]		@ Length of string
	str	r0, [fp, #-8]		@ Preserve file descriptor
	.ifdef	NetBSD
	swi	#10485764		@ 10485760 + write system call
	.else
	mov	r7, #4			@ Write system call
	swi	#0
	.endif
	cmp	r0, #0
	bmi	put_line.end
	str	r0, [fp, #-12]		@ Preserve number
	ldr	r0, [fp, #-8]		@ Restore file descriptor
	mov	r2, #1			@ Length of one byte
	mov	r1, #10			@ New line character
	strb	r1, [fp, #-4]
	sub	r1, fp, #4		@ Create an address for the character
	.ifdef	NetBSD
	swi	#10485764		@ 10485760 + write system call
	.else
	swi	#0
	.endif
	cmp	r0, #0
	bmi	put_line.end
	ldr	r0, [fp, #-12]		@ Restore number
	add	r0, r0, #1		@ Include new line character
put_line.end:
	mov	sp, fp
	.ifdef	NetBSD
	ldr	fp, [sp], #4		@ Restore FP
	.else
	ldm	sp!, {r7, fp}		@ Restore R7 and FP
	.endif
	RET
