mirror of
https://github.com/cc65/cc65.git
synced 2025-04-02 09:29:35 +00:00
Implemented __syschdir on CBM. As getcwd returns a cached directory any direct access to __curunit would cause inconsistencies. Therefore __curunit was renamed to curunit to prohibit user access.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5857 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6618e08bc3
commit
8b26ed2a69
@ -81,10 +81,9 @@
|
||||
|
||||
|
||||
|
||||
/* The file stream implementation and the POSIX I/O functions will use the
|
||||
* following variables to determine the file type and the disk unit to use.
|
||||
/* The file stream implementation and the POSIX I/O functions will
|
||||
* use the following variable to determine the file type to use.
|
||||
*/
|
||||
extern unsigned char _curunit; /* Defaults to current when program started */
|
||||
extern char _filetype; /* Defaults to 's' */
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
|
||||
#--------------------------------------------------------------------------
|
||||
# Rules
|
||||
|
||||
%.o: %.c
|
||||
%.o: %.c
|
||||
@$(CC) $(CFLAGS) $<
|
||||
@$(AS) -o $@ $(AFLAGS) $(*).s
|
||||
|
||||
@ -29,74 +29,75 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
|
||||
#--------------------------------------------------------------------------
|
||||
# Object files
|
||||
|
||||
C_OBJS = cbm_dir.o \
|
||||
cbm_load.o \
|
||||
cbm_save.o \
|
||||
opendir.o \
|
||||
readdir.o \
|
||||
seekdir.o
|
||||
C_OBJS = cbm_dir.o \
|
||||
cbm_load.o \
|
||||
cbm_save.o \
|
||||
opendir.o \
|
||||
readdir.o \
|
||||
seekdir.o
|
||||
|
||||
S_OBJS = c_acptr.o \
|
||||
c_basin.o \
|
||||
c_basin.o \
|
||||
c_bsout.o \
|
||||
c_chkin.o \
|
||||
c_ciout.o \
|
||||
c_ckout.o \
|
||||
c_ciout.o \
|
||||
c_ckout.o \
|
||||
c_clall.o \
|
||||
c_close.o \
|
||||
c_clrch.o \
|
||||
c_getin.o \
|
||||
c_close.o \
|
||||
c_clrch.o \
|
||||
c_getin.o \
|
||||
c_iobase.o \
|
||||
c_listen.o \
|
||||
c_load.o \
|
||||
c_open.o \
|
||||
c_readst.o \
|
||||
c_save.o \
|
||||
c_load.o \
|
||||
c_open.o \
|
||||
c_readst.o \
|
||||
c_save.o \
|
||||
c_setlfs.o \
|
||||
c_setnam.o \
|
||||
c_talk.o \
|
||||
c_talk.o \
|
||||
c_unlsn.o \
|
||||
c_untlk.o \
|
||||
cbm_close.o \
|
||||
cbm_filetype.o \
|
||||
cbm_open.o \
|
||||
cbm_read.o \
|
||||
cbm_write.o \
|
||||
cclear.o \
|
||||
chline.o \
|
||||
clock.o \
|
||||
close.o \
|
||||
closedir.o \
|
||||
ctype.o \
|
||||
cvline.o \
|
||||
devicedir.o \
|
||||
dir.o \
|
||||
diskcmd.o \
|
||||
exehdr.o \
|
||||
filedes.o \
|
||||
filename.o \
|
||||
filetype.o \
|
||||
filevars.o \
|
||||
getdevice.o \
|
||||
cbm_filetype.o \
|
||||
cbm_open.o \
|
||||
cbm_read.o \
|
||||
cbm_write.o \
|
||||
cclear.o \
|
||||
chline.o \
|
||||
clock.o \
|
||||
close.o \
|
||||
closedir.o \
|
||||
ctype.o \
|
||||
cvline.o \
|
||||
devicedir.o \
|
||||
dir.o \
|
||||
diskcmd.o \
|
||||
exehdr.o \
|
||||
filedes.o \
|
||||
filename.o \
|
||||
filetype.o \
|
||||
filevars.o \
|
||||
getdevice.o \
|
||||
gotox.o \
|
||||
gotoxy.o \
|
||||
gotoy.o \
|
||||
initcwd.o \
|
||||
loadaddr.o \
|
||||
open.o \
|
||||
oserrlist.o \
|
||||
initcwd.o \
|
||||
loadaddr.o \
|
||||
open.o \
|
||||
oserrlist.o \
|
||||
oserror.o \
|
||||
read.o \
|
||||
rewinddir.o \
|
||||
rwcommon.o \
|
||||
scratch.o \
|
||||
sysremove.o \
|
||||
sysrename.o \
|
||||
telldir.o \
|
||||
toascii.o \
|
||||
wherex.o \
|
||||
wherey.o \
|
||||
write.o
|
||||
read.o \
|
||||
rewinddir.o \
|
||||
rwcommon.o \
|
||||
scratch.o \
|
||||
syschdir.o \
|
||||
sysremove.o \
|
||||
sysrename.o \
|
||||
telldir.o \
|
||||
toascii.o \
|
||||
wherex.o \
|
||||
wherey.o \
|
||||
write.o
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Targets
|
||||
@ -109,4 +110,3 @@ clean:
|
||||
@$(RM) *~ *.bck $(C_OBJS:.o=.s) $(C_OBJS) $(S_OBJS)
|
||||
|
||||
zap: clean
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
.export fnunit, fnlen, fnisfile, fncmd, fnbuf
|
||||
|
||||
.import SETNAM
|
||||
.import __curunit, __filetype
|
||||
.import curunit, __filetype
|
||||
.importzp ptr1, tmp1
|
||||
|
||||
.include "ctype.inc"
|
||||
@ -147,7 +147,7 @@ drivedone:
|
||||
|
||||
.proc fndefunit
|
||||
|
||||
lda __curunit
|
||||
lda curunit
|
||||
sta fnunit
|
||||
rts
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
; Variables used for CBM file I/O
|
||||
;
|
||||
|
||||
.export __curunit
|
||||
.export curunit
|
||||
.constructor initcurunit, 30
|
||||
.importzp devnum
|
||||
|
||||
|
||||
.bss
|
||||
|
||||
__curunit:
|
||||
curunit:
|
||||
.res 1
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ __curunit:
|
||||
bne @L0
|
||||
lda #8 ; Default is disk
|
||||
sta devnum
|
||||
@L0: sta __curunit
|
||||
@L0: sta curunit
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -5,7 +5,7 @@
|
||||
;
|
||||
|
||||
.export initcwd, devicestr
|
||||
.import __curunit, __cwd
|
||||
.import curunit, __cwd
|
||||
.import pusha0, tosudiva0
|
||||
.importzp sreg, ptr1, ptr2
|
||||
|
||||
@ -16,7 +16,7 @@ initcwd:
|
||||
ldx #>__cwd
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
lda __curunit
|
||||
lda curunit
|
||||
; Fall through
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@ -28,11 +28,11 @@ devicestr:
|
||||
jsr tosudiva0
|
||||
ldy #0
|
||||
lda sreg
|
||||
beq :+ ; >=10
|
||||
beq @L0 ; >=10
|
||||
add #'0'
|
||||
sta (ptr2),y
|
||||
iny
|
||||
: lda ptr1 ; rem
|
||||
@L0: lda ptr1 ; rem
|
||||
add #'0'
|
||||
sta (ptr2),y
|
||||
iny
|
||||
|
86
libsrc/cbm/syschdir.s
Normal file
86
libsrc/cbm/syschdir.s
Normal file
@ -0,0 +1,86 @@
|
||||
;
|
||||
; Oliver Schmidt, 2012-10-16
|
||||
;
|
||||
; unsigned char __fastcall__ _syschdir (const char* name);
|
||||
;
|
||||
|
||||
.export __syschdir
|
||||
.import curunit, initcwd
|
||||
.importzp ptr1, tmp1, tmp2
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; __syschdir
|
||||
|
||||
.proc __syschdir
|
||||
|
||||
; Save name
|
||||
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
|
||||
; Process first character
|
||||
|
||||
ldy #0
|
||||
lda (ptr1),y
|
||||
beq err
|
||||
jsr getdigit
|
||||
bcs err
|
||||
tax
|
||||
|
||||
; Process second character
|
||||
|
||||
iny
|
||||
lda (ptr1),y
|
||||
beq done
|
||||
jsr getdigit
|
||||
bcs err
|
||||
stx tmp1 ; First digit
|
||||
sta tmp2 ; Second digit
|
||||
|
||||
; Multiply first digit by 10
|
||||
|
||||
ldx #8
|
||||
@L0: asl
|
||||
asl tmp1
|
||||
bcc @L1
|
||||
clc
|
||||
adc #10
|
||||
@L1: dex
|
||||
bne @L0
|
||||
|
||||
; Add second digit to product
|
||||
|
||||
clc
|
||||
adc tmp2
|
||||
tax
|
||||
|
||||
; Process third character
|
||||
|
||||
iny
|
||||
lda (ptr1),y
|
||||
bne err
|
||||
|
||||
; Success, update cwd
|
||||
|
||||
done: stx curunit
|
||||
jmp initcwd ; Returns with A = 0
|
||||
|
||||
err: lda #9 ; "Ilegal device"
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; getdigit
|
||||
|
||||
.proc getdigit
|
||||
|
||||
sec
|
||||
sbc #'0'
|
||||
bcs @L0
|
||||
sec
|
||||
rts
|
||||
@L0: cmp #10
|
||||
rts
|
||||
|
||||
.endproc
|
Loading…
x
Reference in New Issue
Block a user