1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00
cc65/libsrc/cbm/syschdir.s
ol.sc 1a80cd1071 Added check for disk in drive on chdir().
git-svn-id: svn://svn.cc65.org/cc65/trunk@5859 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-10-17 20:24:43 +00:00

95 lines
1.6 KiB
ArmAsm

;
; Oliver Schmidt, 2012-10-16
;
; unsigned char __fastcall__ _syschdir (const char* name);
;
.export __syschdir
.import diskinit, fnunit, 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 init
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
; Check device readiness
init: txa
jsr diskinit
bne done
; Success, update cwd
lda fnunit ; Set by diskinit
sta curunit
jmp initcwd ; Returns with A = 0
; Return with error in A
err: lda #9 ; "Ilegal device"
done: rts
.endproc
;--------------------------------------------------------------------------
; getdigit
.proc getdigit
sec
sbc #'0'
bcs @L0
sec
rts
@L0: cmp #10
rts
.endproc