Skip to content

Commit 9dabbec

Browse files
committed
fix bug when 2 files are opened and the second is closed and opened : overflow in fp ptr of the process
1 parent 17708c4 commit 9dabbec

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

src/functions/files/xclose.asm

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
sta RESB
1111
sty RESB + 1 ; save fp
1212

13-
.ifdef WITH_DEBUG
14-
pha
15-
ldx #XDEBUG_FCLOSE_ENTER
16-
jsr xdebug_print_with_a
17-
pla
18-
.endif
13+
1914

2015
; Try to found FP
2116
; kernel_process+kernel_process_struct::kernel_fd contient un tableau où la position 0 est le FD 3 (car on commence à 3 avec stin- 0 , stdout, stderr)
@@ -34,25 +29,13 @@
3429
lda kernel_process + kernel_process_struct::kernel_fd,x ; A contient l'id du process, X contient l'id du FD retranché de 3
3530
bne @found_fp_slot
3631

37-
.ifdef WITH_DEBUG
38-
jsr kdebug_save
39-
txa
40-
ldx #XDEBUG_XCLOSE_FD_NOT_FOUND
41-
jsr xdebug_print_with_a
42-
jsr kdebug_restore
43-
.endif
32+
4433
@exit:
4534
rts
4635

4736
@found_fp_slot:
4837
; Process should be called here
49-
.ifdef WITH_DEBUG
50-
pha
51-
lda RESB
52-
ldx #XDEBUG_XCLOSE_FD_FOUND
53-
jsr xdebug_print
54-
pla
55-
.endif
38+
5639

5740
txa ; Transfert fd 'id slot'
5841
asl ; Multiply * 2
@@ -98,7 +81,11 @@
9881
jsr XFREE_ROUTINE
9982

10083
; Clear fp in current process
101-
ldy #kernel_one_process_struct::fp_ptr
84+
lda TR7
85+
asl
86+
clc
87+
adc #kernel_one_process_struct::fp_ptr
88+
tay
10289
lda #$00
10390
sta (RESB),y
10491
iny

0 commit comments

Comments
 (0)