allocate local vars in .data, don't use the stack (we don't need to

be reentrant here :-)


git-svn-id: svn://svn.cc65.org/cc65/trunk@55 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cpg 2000-06-11 23:21:30 +00:00
parent 269ae9606d
commit af33f993e1

View file

@ -14,7 +14,7 @@
.export newfd .export newfd
.export getfd .export getfd
.export _fd_table,_fd_index .export _fd_table,_fd_index ; for test purposes
.data .data
MAX_FD_INDEX = 12 MAX_FD_INDEX = 12
@ -180,14 +180,15 @@ ret: rts
; ptr4 - 3,4 (backup) ; ptr4 - 3,4 (backup)
; devnum - 5 ; devnum - 5
;loc_A = 0 .data
;loc_X = 1 loc_Y: .res 1
loc_Y = 0 loc_ptr4_l: .res 1
loc_ptr4_l = 1 loc_ptr4_h: .res 1
loc_ptr4_h = 2 loc_tmp1: .res 1
loc_tmp1 = 3 loc_devnum: .res 1
loc_devnum = 4 loc_size: .res 1
loc_size = 5
.code
.proc newfd .proc newfd
@ -197,33 +198,21 @@ loc_size = 5
tya tya
pha pha
ldy #loc_size ldx #0
jsr subysp stx loc_devnum
ldy #loc_devnum
lda #0
sta (sp),y ; loc_devnum
dey
lda tmp1 lda tmp1
sta (sp),y ; loc_tmp1 sta loc_tmp1
lda #0 stx tmp1 ; init tmp1
sta tmp1 ; init tmp1 stx tmp2 ; init tmp2
sta tmp2 ; init tmp2
dey
lda ptr4+1 lda ptr4+1
sta (sp),y ; loc_ptr4_h sta loc_ptr4_h
dey
lda ptr4 lda ptr4
sta (sp),y ; loc_ptr4_l sta loc_ptr4_l
dey
pla pla
sta (sp),y ; loc_Y sta loc_Y
; dey
pla pla
; sta (sp),y ; loc_X
sta ptr4+1 sta ptr4+1
; dey
pla pla
; sta (sp),y ; loc_A
sta ptr4 sta ptr4
; ptr4 points to filename ; ptr4 points to filename
@ -284,11 +273,9 @@ l1: ldy #0
l2: sta fd_table+ft_dev,x ; set device l2: sta fd_table+ft_dev,x ; set device
lda #1 lda #1
sta fd_table+ft_usa,x ; set usage counter sta fd_table+ft_usa,x ; set usage counter
ldy #loc_Y lda loc_Y
lda (sp),y
sta fd_table+ft_iocb,x ; set iocb index sta fd_table+ft_iocb,x ; set iocb index
ldy #loc_devnum lda loc_devnum
lda (sp),y ; get (optional) device number
and #7 ; only 3 bits and #7 ; only 3 bits
sta fd_table+ft_flag,x sta fd_table+ft_flag,x
lda tmp2 lda tmp2
@ -305,8 +292,7 @@ colon2: dey
sec sec
sbc #'0' sbc #'0'
and #7 and #7
ldy #loc_devnum sta loc_devnum
sta (sp),y ; save it
sta tmp2 ; save it for speed later here also sta tmp2 ; save it for speed later here also
lda #4 ; max. length if only device + number ("Xn:") lda #4 ; max. length if only device + number ("Xn:")
cmp tmp3 cmp tmp3
@ -363,16 +349,12 @@ finish: lda ptr4
pha pha
lda ptr4+1 lda ptr4+1
pha pha
ldy #loc_Y lda loc_Y
lda (sp),y
pha pha
lda tmp1 lda tmp1
pha pha
ldy #loc_tmp1 lda loc_tmp1
lda (sp),y
sta tmp1 sta tmp1
ldy #loc_size
jsr addysp
pla pla
lsr a ; set C as needed lsr a ; set C as needed