Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@3374 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export _vfprintf
|
.export _vfprintf
|
||||||
.import pushax, popax, push1
|
.import pushax, popax, push1, pushwysp, ldaxysp, ldaxidx, incsp6
|
||||||
.import _fwrite, __printf
|
.import _fwrite, __printf
|
||||||
.importzp sp, ptr1, ptr2
|
.importzp sp, ptr1, ptr2
|
||||||
|
|
||||||
@@ -45,31 +45,28 @@ out:
|
|||||||
|
|
||||||
; About to call
|
; About to call
|
||||||
;
|
;
|
||||||
; fwrite (buf, count, 1, (FILE*) d->ptr);
|
; fwrite (buf, 1, count, (FILE*) d->ptr);
|
||||||
;
|
;
|
||||||
; Since Buf and Count are already in place, we will just push the last
|
; Since Buf and Count are already in place, we will just push the last
|
||||||
; two parameters. The fwrite function will remove Buf and Count on exit.
|
; two parameters. The fwrite function will remove Buf and Count on exit.
|
||||||
|
|
||||||
jsr push1
|
ldy #5
|
||||||
ldy #7 ; Offset of D+1 on stack
|
jsr pushwysp ; Push buf
|
||||||
lda (sp),y
|
jsr push1 ; Push #1
|
||||||
sta ptr1+1
|
ldy #7
|
||||||
dey ; Offset of D on stack (6)
|
jsr pushwysp ; Push count
|
||||||
lda (sp),y
|
ldy #11 ; Current offset of D
|
||||||
sta ptr1
|
jsr ldaxysp ; Load D
|
||||||
dey ; Offset of ptr+1 in struct outdesc (5)
|
ldy #5 ; Offset of ptr1+1 in struct outdesc
|
||||||
lda (ptr1),y
|
jsr ldaxidx ; Load
|
||||||
tax
|
|
||||||
dey
|
|
||||||
lda (ptr1),y ; Load D->ptr
|
|
||||||
jsr _fwrite
|
jsr _fwrite
|
||||||
sta ptr2 ; Save function result
|
sta ptr2 ; Save function result
|
||||||
stx ptr2+1
|
stx ptr2+1
|
||||||
|
|
||||||
; Pop the last parameter from stack and store it in ptr1. This means that
|
; Get D and store it in ptr1
|
||||||
; the stack is clean now.
|
|
||||||
|
|
||||||
jsr popax
|
ldy #5
|
||||||
|
jsr ldaxysp
|
||||||
sta ptr1
|
sta ptr1
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
|
|
||||||
@@ -77,7 +74,7 @@ out:
|
|||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
|
|
||||||
; Check the return code. Checking the hig byte against $FF is ok here.
|
; Check the return code. Checking the high byte against $FF is ok here.
|
||||||
|
|
||||||
lda ptr2+1
|
lda ptr2+1
|
||||||
cmp #$FF
|
cmp #$FF
|
||||||
@@ -87,19 +84,18 @@ out:
|
|||||||
|
|
||||||
sta (ptr1),y
|
sta (ptr1),y
|
||||||
iny
|
iny
|
||||||
sta (ptr1),y
|
bne @Done ; Branch always
|
||||||
rts
|
|
||||||
|
|
||||||
; Result was ok, count bytes written
|
; Result was ok, count bytes written
|
||||||
|
|
||||||
@Ok: lda (ptr1),y
|
@Ok: lda (ptr1),y
|
||||||
add ptr1
|
add ptr2
|
||||||
sta (ptr1),y
|
sta (ptr1),y
|
||||||
iny
|
iny
|
||||||
lda (ptr1),y
|
lda (ptr1),y
|
||||||
adc ptr1+1
|
adc ptr2+1
|
||||||
sta (ptr1),y
|
@Done: sta (ptr1),y
|
||||||
rts
|
jmp incsp6 ; Drop stackframe
|
||||||
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user