From d1d9ebe9e77e922ef7fa08f7624c4eba09e4d925 Mon Sep 17 00:00:00 2001
From: cpg <cpg@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Date: Tue, 30 May 2000 22:21:40 +0000
Subject: [PATCH] initialze stdin/stdout/stderr correctly

git-svn-id: svn://svn.cc65.org/cc65/trunk@17 b7a2c559-68d2-44c3-8de9-860c34a00d81
---
 libsrc/atari/crt0.s | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s
index 39235e013..66222d248 100644
--- a/libsrc/atari/crt0.s
+++ b/libsrc/atari/crt0.s
@@ -12,7 +12,7 @@
 	.export		_exit
 	.import		getargs, argc, argv
 	.import		__hinit, initconio, zerobss, pushax, doatexit
-	.import		_main,__filetab
+	.import		_main,__filetab,getfd
 	.import		__CODE_LOAD__, __BSS_LOAD__
 
 	.include	"atari.inc"
@@ -115,14 +115,17 @@ L1:	lda	sp,y
 	lda	#$FF
 	sta	CH
 
-; ugly hack for now: set stdio stream handles
-; all to iocb #0
-; until we know where to go with fd<->iocb relation
-; this won't stay here!
+; set stdio stream handles
 
 	lda	#0
-	sta	__filetab + 2
-	sta	__filetab + 4
+	jsr	getfd
+	sta	__filetab		; setup stdin
+	lda	#0
+	jsr	getfd
+	sta	__filetab + 2		; setup stdout
+	lda	#0
+	jsr	getfd
+	sta	__filetab + 4		; setup stderr
 
 ; Pass command line if present