Files
Sprinter-SDCC/third_party/solid-c/SRC/CLIB/DOS.ASM
T
snark13 c71e249a4e Add full compiler toolchain, libc, examples and reference docs
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.

What's in here:
  bin/sprinter-cc        — driver script invoking SDCC + linker + mkexe
  libc/                  — Sprinter-specific libc layer over ESTEX/BIOS
                           (conio, gfx, io, mem, stdio + headers)
  runtime/               — crt0 variants (default/small/banked/minimal)
                           + heap + bank trampolines
  toolchain/             — mkexe (SprintEXE packer, C + tests)
  examples/              — 30 demo programs (gfx, file I/O, env, time, …)
  lib/Makefile           — builds the libc archive (sprinter.lib)
  docs/                  — converted Sprinter manuals + asm reference samples
  third_party/           — solid-c reference compiler dump + sdcc setup script
  release_docs/          — packaging / release notes

gitignore overhaul:
  • Drop dangerous blanket patterns: *.asm (would hide docs/samples/*.asm)
    and *.exe (case-insensitive match was hiding third_party/solid-c/*.EXE
    on macOS APFS).  Replaced with examples/*/*.{asm,exe,…} and lib/*.lib.
  • Restore tracking of toolchain/mkexe/tests/{one,big}.bin — those are
    INPUT fixtures, not build outputs.
  • Collapse the duplicated SDCC/C/Sdcc sections into one section per
    concern (build outputs / vendored / OS-junk).
  • Add .sprinter-cc-*/, build/ (catches lib/build/ too), .claude/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 16:13:21 +03:00

619 lines
12 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
; ”㭪樨 ¯à®¢¥à¥­ë.
;
; ‚室ï騥 ä㭪樨:
;
; bdos
; bdosh
; enable
; disable
; _setargv
; setdisk
; getdisk
; absread
; abswrite
; setdate
; getdate
; settime
; gettime
; intdos
; ffirst (findfirst)
; fnext (findnext)
;
MODULE bdos
;
; "dos.h"
; ‚믮«­ï¥â á¨á⥬­ë© ¢ë§®¢ „Ž‘, ­®¬¥à ª®â®à®£® ®¯à¥¤¥«¥­ ¢ n.
; €à£ã¬¥­âë doshl ¨ dosa à §¬¥é îâáï ᮮ⢥âá⢥­­® ¢ ॣ¨áâà å HL ¨ A.
; ”ã­ªæ¨ï ¢ë¯®«­ï¥â ª®¬ ­¤ã RST 10h ¤«ï ®áãé¥á⢫¥­¨ï á¨á⥬­®£® ¢ë§®¢ .
; ”ã­ªæ¨ï ¬®¦¥â ¡ëâì ¨á¯®«ì§®¢ ­  ⮫쪮 ¤«ï á¨á⥬­ëå „Ž‘-¢ë§®¢®¢, ª®â®àë¥
; ­¥ ¯à¨­¨¬ îâ  à£ã¬¥­â®¢ ¨«¨ ¯à¨­¨¬ îâ ¨å ⮫쪮 ¢ ॣ¨áâà å HL ¨ A.
; ”ã­ªæ¨ï ¢®§¢à é ¥â §­ ç¥­¨¥ ॣ¨áâà  A, § ¯®«­¥­­®£® á¨á⥬­ë¬ ¢ë§®¢®¬.
; ਬ¥ç ­¨¥: âã äã­ªæ¨î ­¥«ì§ï ¨á¯®«ì§®¢ âì ¤«ï ®áãé¥á⢫¥­¨ï á¨á⥬­ëå
; ¢ë§®¢®¢, ¢ ª®â®àëå ®è¨¡ª¨ 㪠§ë¢ îâáï ¯®á।á⢮¬ ãáâ ­®¢ª¨ ä« £  ¯¥à¥­®á .
; ’.ª. ‘¨-¯à®£à ¬¬ë ­¥ ¨¬¥îâ ¤®áâ㯠 ª í⮬ã ä« £ã, áâ âãá ¢®§¢à é ¥¬®£®
; §­ ç¥­¨ï ®¯à¥¤¥«¨âì ­¥¢®§¬®¦­®. ‚ í⮬ á«ãç ¥ ­¥®¡å®¤¨¬® ¨á¯®«ì§®¢ âì
; äã­ªæ¨î intdos.
; ”ã­ªæ¨ï bdosh ®â«¨ç ¥âáï ®â bdos ⮫쪮 ⥬, çâ® ¢®§¢à é ¥¬®¥ §­ ç¥­¨¥
; ᮤ¥à¦¨âáï ¢ ॣ. ¯ à¥ HL.
; Ž¡¥ ä㭪樨 ¬®¦­® ¨á¯®«ì§®¢ âì ¤«ï „Ž‘-¢ë§®¢®¢: 02h,0Ah,0Bh,0Eh,11h,1Bh
; 1Ch,1Dh,1Eh,5Ch ä㭪権.
;
; in: a = ­®¬¥à ä㭪樨
; de = ¯¥à¥¤ ¢ ¥¬ë¥ ¯ à ¬¥âàë
; c =  âਡãâ
; out: a = §­ ç¥­¨¥ á¨á⥬­®£® ¢ë§®¢ 
;
; char bdos(char n, int doshl, char dosa)
; int bdosh(char n, int doshl, char dosa)
;
bdosh_::
bdos_::
ld b,c
ld c,a ; c = n
ld a,b ; a = dosa
ex de,hl ; hl = doshl
push ix
rst 10h
pop ix
ld l,a
ld h,0
ret
ENDMODULE
MODULE diei
;
; "dos.h"
; Enable and disable interrupts.
;
; in: ­¥â
; out: ­¥â
;
; void enable()
; void disable()
;
enable_::
ei
ret
disable_::
di
ret
ENDMODULE
MODULE setarg
;-----------------------------------------------------------
; ¢­ãâ७­ïï: ¢ë§ë¢ ¥âáï ¨§ xmain ¤«ï ä㭪樨 _main_
;-----------------------------------------------------------
; ‘®§¤ âì ᯨ᮪  à£ã¬¥­â®¢, § ¤ ­­ëå ¢ ª®¬ ­¤­®© áâப¥.
; ‚®§¢à é ¥âáï ç¨á«®  à£ã¬¥­â®¢. ‘¯¨á®ª à áç¨â ­ ­   ¤à¥á 
; ¬ ªá¨¬ã¬ 30  à£ã¬¥­â®¢.
;
; in: hl =  ¤à¥á ª®¬. áâப¨
; out: hl = ç¨á«®  à£ã¬¥­â®¢ (argc)
;
; int _setargv(*string)
;
_setargv::
ld c,(hl) ; ¤«¨­  ª®¬. áâப¨
inc hl
ld b,0
ld e,l ; ­ ç «® ª®¬. áâப¨
ld d,h
add hl,bc
ld (hl),b ; ­ã«ì ¢ ª®­¥æ ª®¬. áâப¨
;  ¤à¥á ¨¬¥­¨ ¯à®£à ¬¬ë
push de
inc hl
inc hl
ld b,122
@6: ld a,(hl)
inc hl
or a
jr z,@8
cp "\"
jr nz,@7
ld e,l
ld d,h
@7: djnz @6
@8: ld (_argv_),de ;  ¤à¥á ¨¬¥­¨ ¯à®£à ¬¬ë
pop de
;
ld hl,_argv_+2 ; ᯨ᮪  ¤à¥á®¢  à£ã¬¥­â®¢
ld b,1 ; b=1 argc!
@1: ld a,(de)
inc de
cp " "
jr z,@1
cp 9 ; Tab
jr z,@1
or a
jr z,@2 ; ª®­¥æ áâப¨
dec de
ld (hl),e ;  ¤à¥á  à£ã¬¥­â  ¢ ᯨ᮪
inc hl
ld (hl),d
inc hl
inc b ; ++argc
@3: ld a,(de)
cp " "
jr z,@4
cp 9 ; Tab
jr z,@4
or a
jr z,@2 ; ª®­¥æ áâப¨
inc de
cp '"'
jr z,@5
jr @3
;
@4: xor a
ld (de),a ; ­ã«ì ¢ ª®­¥æ  à£ã¬¥­â  ¢ ª®¬. áâப¥
inc de
jr @1
;
@5: ld a,(de)
cp '"'
jr z,@3
or a
jr z,@2
inc de
jr @5
;
; ª®­¥æ  à£ã¬¥­â®¢
@2: ld (hl),0 ; null
inc hl
ld (hl),0
ld l,b ; hl=ç¨á«®  à£ã¬¥­â®¢
ld h,0
ret
dseg
_argv_::
ds 32*2 ; ᯨ᮪  ¤à¥á®¢  à£ã¬¥­â®¢
ENDMODULE
MODULE setdisk
;
; "dos.h"
; “áâ ­®¢¨âì ⥪ã騩 ¤¨áª
;
; in: a = ­®¬¥à ¤¨áª 
; out: ­¥â
;
; void setdisk(char diskno)
;
setdisk_::
push ix
ld c,1
rst 10h
pop ix
ret
ENDMODULE
MODULE absread
;
; "dos.h"
; €¡á®«îâ­®¥ ç⥭¨¥ á ¤¨áª .
; ”ã­ªæ¨ï áç¨â뢠¥â ¢ ¡ãä¥à ®¤¨­ ¨«¨ ­¥áª®«ìª® ᥪâ®à®¢
; á § ¤ ­­ë¬ ­ ç «ì­ë¬ ®â­®á¨â¥«ì­ë¬ ­®¬¥à®¬. ‘¥ªâ®àë
; ­ã¬¥àãîâáï á 0 ®â ­ ç «  «®£¨ç¥áª®£® (­¥ 䨧¨ç¥áª®£®!)
; ¤¨áª . Š ¯à¨¬¥àã, § £àã§®ç­ë© ᥪâ®à ¤ ­­®£® «®£¨ç¥áª®£®
; ¤¨áª  ¨¬¥¥â ­®¬¥à 0, ¤ «¥¥ ¯¥à¢ ï ª®¯¨ï FAT ­ ç¨­ ¥âáï
; á ᥪâ®à  ­®¬¥à 1 ¨ â.¤.
; ”ã­ªæ¨ï ¢®§¢à é îâ 0 ¯à¨ ãᯥ譮¬ § ¢¥à襭¨¨ ®¯¥à æ¨¨.
; ‚ á«ãç ¥ ®è¨¡ª¨ ¢®§¢à é ¥âáï -1 (0FFh) ¨ errno ᮤ¥à¦¨â
; ­®¬¥à ®è¨¡ª¨.
;
; in: a = ­®¬¥à ¤¨áª 
; de = «®£. ­®¬¥à ᥪâ®à 
; bc = ª®«-¢® ç¨â ¥¬ëå ᥪâ®à®¢
; á⥪ =  ¤à¥á ¡ãä¥à 
; out: a = 0 - Ok
; a = -1 - Error
;
; char absread(char disk, int nsect, char count, char buffer)
;
; disk - ­®¬¥à ¤¨áª 
; nsect - ­®¬¥à ­ ç «ì­®£® ᥪâ®à 
; count - ª®«-¢® ç¨â ¥¬ëå ᥪâ®à®¢
; buffer -  ¤à¥á ¡ãä¥à  ¯®¤ áç¨â뢠¥¬ë¥ ¤ ­­ë¥
;
absread_::
ld (@1+2),ix
ld lx,e ; ix=nsect
ld hx,d
pop hl
pop de ; de= ¤à¥á buffer
push de
push hl
ld hl,0 ; áâ.à §àï¤ ­®¬¥à  ᥪâ®à 
ld b,c ; count
ld c,55h
rst 08h
jr c,@2
xor a ; Ok
@1: ld ix,0
ret
@2: ld a,25 ; EREAD (read error)
ld (errno_##),a
ld a,-1
jr @1
ENDMODULE
MODULE abswrit
;
; "dos.h"
; €¡á®«îâ­ ï § ¯¨áì ­  ¤¨áª.
; ”ã­ªæ¨ï § ¯¨á뢠¥â ¨§ ¡ãä¥à  ®¤¨­ ¨«¨ ­¥áª®«ìª® ᥪâ®à®¢
; á § ¤ ­­ë¬ ­ ç «ì­ë¬ ®â­®á¨â¥«ì­ë¬ ­®¬¥à®¬. ‘¥ªâ®àë
; ­ã¬¥àãîâáï á 0 ®â ­ ç «  «®£¨ç¥áª®£® (­¥ 䨧¨ç¥áª®£®!)
; ¤¨áª . Š ¯à¨¬¥àã, § £àã§®ç­ë© ᥪâ®à ¤ ­­®£® «®£¨ç¥áª®£®
; ¤¨áª  ¨¬¥¥â ­®¬¥à 0, ¤ «¥¥ ¯¥à¢ ï ª®¯¨ï FAT ­ ç¨­ ¥âáï
; á ᥪâ®à  ­®¬¥à 1 ¨ â.¤.
; ”ã­ªæ¨ï ¢®§¢à é îâ 0 ¯à¨ ãᯥ譮¬ § ¢¥à襭¨¨ ®¯¥à æ¨¨.
; ‚ á«ãç ¥ ®è¨¡ª¨ ¢®§¢à é ¥âáï -1 (0FFh) ¨ errno ᮤ¥à¦¨â
; ­®¬¥à ®è¨¡ª¨.
;
; in: a = ­®¬¥à ¤¨áª 
; de = «®£. ­®¬¥à ᥪâ®à 
; bc = ª®«-¢® § ¯¨á뢠¥¬ëå ᥪâ®à®¢
; out: a = 0 - Ok
; a = -1 - Error
;
; char abswrite(char disk, int nsect, char count, char buffer)
;
; disk - ­®¬¥à ¤¨áª 
; nsect - ­®¬¥à ­ ç «ì­®£® ᥪâ®à 
; count - ª®«-¢® § ¯¨á뢠¥¬ëå ᥪâ®à®¢
; buffer -  ¤à¥á ¡ãä¥à  ¤ ­­ëå
;
abswrite_::
ld (@1+2),ix
ld lx,e ; ix=nsect
ld hx,d
pop hl
pop de ; de= ¤à¥á buffer
push de
push hl
ld hl,0 ; áâ.à §àï¤ ­®¬¥à  ᥪâ®à 
ld b,c ; count
ld c,56h
rst 08h
jr c,@2
xor a ; Ok
@1: ld ix,0
ret
@2: ld a,26 ; EWRITE (write error)
ld (errno_##),a
ld a,-1
jr @1
ENDMODULE
MODULE getdisk
;
; "dos.h"
; “§­ âì ­®¬¥à ¤¨áª 
;
; in: ­¥â
; out: a = ­®¬¥à ¤¨áª 
;
; char getdisk()
;
getdisk_::
;push ix
ld c,2
rst 10h
;pop ix
ret
ENDMODULE
MODULE getdate
;
; "dos.h"
; “§­ âì á¨á⥬­ãî ¤ âã ¨ § ¯®«­¨âì áâàãªâãàã date.
;
; in: hl =  ¤à¥á áâàãªâãàë ¤ âë
; out: ­¥â
;
; void getdate(struct date *date)
;
getdate_::
push ix
push hl ;  ¤à¥á áâàãªâãàë ¤ âë
ld c,21h
rst 10h
pop hl
push ix
pop bc
ld (hl),c ;+0 £®¤
inc hl ;
ld (hl),b ;+1
inc hl
ld (hl),d ;+2 ¤¥­ì
inc hl
ld (hl),e ;+3 ¬¥áïæ
pop ix
ret
ENDMODULE
MODULE setdate
;
; "dos.h"
; “áâ ­®¢¨âì á¨á⥬­ãî ¤ âã.
;
; in: hl =  ¤à¥á áâàãªâãàë ¤ âë
; out: ­¥â
;
; void setdate(struct date *date)
;
setdate_::
push ix
ld c,(hl) ;+0 £®¤
inc hl ;
ld b,(hl) ;+1
inc hl
ld d,(hl) ;+2 ¤¥­ì
inc hl
ld e,(hl) ;+3 ¬¥áïæ
push bc
pop ix
ld c,22h
rst 10h
pop ix
ret
ENDMODULE
MODULE gettime
;
; "dos.h"
; “§­ âì á¨á⥬­®¥ ¢à¥¬ï ¨ § ¯®«­¨âì áâàãªâãàã time.
;
; in: hl =  ¤à¥á áâàãªâãàë ¢à¥¬¥­¨
; out: ­¥â
;
; void gettime(struct time *time)
;
gettime_::
push ix
push hl
ld c,21h
rst 10h
ex de,hl
pop hl
ld (hl),e ;+0 ¬¨­ãâë
inc hl
ld (hl),d ;+1 ç áë
inc hl
inc hl ; ®¡®©â¨ ï祩ªã "ti_hund"
ld (hl),b ;+3 ᥪ㭤ë
pop ix
ret
ENDMODULE
MODULE settime
;
; "dos.h"
; “áâ ­®¢¨âì á¨á⥬­®¥ ¢à¥¬ï.
;
; in: hl =  ¤à¥á áâàãªâãàë ¢à¥¬¥­¨
; out: ­¥â
;
; void settime(struct time *time)
;
settime_::
push ix
ld e,(hl) ;+0 ¬¨­ãâë
inc hl
ld d,(hl) ;+1 ç áë
inc hl
inc hl ; ®¡®©â¨ ï祩ªã "ti_hund"
ld b,(hl) ;+3 ᥪ㭤ë
ex de,hl
ld c,22h
rst 10h
pop ix
ret
ENDMODULE
MODULE intdos
;
; "dos.h"
; ”ã­ªæ¨ï intdos ®áãé¥á⢫ï¥â ¢ë¯®«­¥­¨¥ á¨á⥬­®£® „Ž‘-¢ë§®¢  (á ¢®§¢à â®¬
; ä« £®¢ ãá«®¢¨©), ª®â®àë© ®¯à¥¤¥«¥­ §­ ç¥­¨ï¬¨ ॣ¨áâ஢, ®¡ê¥­­ëå ¢
; union REGS *ri ¨ ¢®§¢à é ¥â १ã«ìâ â á¨á⥬­®£® ¢ë§®¢  ¢ union REGS *ro.
; ’¨¯ ®¡ê¥¤¨­¥­¨ï union REGS ®¡ê¥­ ¢ "dos.h".
; „«ï ®áãé¥á⢫¥­¨ï á¨á⥬­®£® ¢ë§®¢  intdos ¢ë¯®«­ï¥â ª®¬ ­¤ã RST 10h.
; ¥à¥¤ ¢ë¯®«­¥­¨¥¬ ª®¬ ­¤ë äã­ªæ¨ï ª®¯¨àã¥â ᮤ¥à¦¨¬®¥ union REGS *ri ¢
; ᮮ⢥âáâ¢ãî騥 ॣ¨áâàë. ®á«¥ ¢ë¯®«­¥­¨ï ª®¬ ­¤ë RST, äã­ªæ¨ï intdos
; ª®¯¨àã¥â §­ ç¥­¨ï ⥪ãé¨å ॣ¨áâ஢ ¢ union REGS *ro. Ž­  â ª¦¥ ª®¯¨àã¥â
; ¢®§¢à é ¥¬ë© ä« £ ãá«®¢¨© á¨áâ¥¬ë ¢ ¯®«¥ flag, à §¬¥é¥­­®¥ ¢ union REGS *ro.
; …᫨ íâ® ¯®«¥ ï¥âáï ­¥­ã«¥¢ë¬, ä« £ 㪠§ë¢ ¥â ­  ãá«®¢¨¥ ®è¨¡ª¨.
;
; union REGS *ri - §­ ç¥­¨ï ॣ¨áâ஢ ¯à¨ ¢ë§®¢¥
; union REGS *ro - §­ ç¥­¨ï ॣ¨áâ஢ ¯à¨ ¢®§¢à â¥
;
; in: hl =  ¤à¥á union REGS *ri
; de =  ¤à¥á union REGS *ro
; out: ­¥â
;
; void intdos(union REGS *ri, union REGS *ro)
;
intdos_::
push ix
push de ; de=REGS *ro
inc hl
ld a,(hl) ;+1 a
inc hl
ld c,(hl) ;+2
inc hl
ld b,(hl) ;+3
push bc
inc hl
ld e,(hl) ;+4
inc hl
ld d,(hl) ;+5
push de
inc hl
ld e,(hl) ;+6 l
inc hl
ld d,(hl) ;+7 h
inc hl
ld c,(hl) ;+8 xl
inc hl
ld b,(hl) ;+9 xh
push bc
pop ix
inc hl
ld c,(hl) ;+10 yl
inc hl
ld b,(hl) ;+11 yh
push bc
pop iy
ex de,hl ; hl
pop de
pop bc
rst 10h ; á¨á⥬­ë© „Ž‘-¢ë§®¢
ex (sp),hl ; hl=REGS *ro
push bc
push af
pop bc
ld (hl),c ;+0 flag
inc hl
ld (hl),b ;+1 a
pop bc
inc hl
ld (hl),c ;+2
inc hl
ld (hl),b ;+3
inc hl
ld (hl),e ;+4
inc hl
ld (hl),d ;+5
inc hl
pop de
ld (hl),e ;+6 l
inc hl
ld (hl),d ;+7 h
push ix
pop bc
inc hl
ld (hl),c ;+8 xl
inc hl
ld (hl),b ;+9 xh
push iy
pop bc
inc hl
ld (hl),c ;+10 yl
inc hl
ld (hl),b ;+11 yh
pop ix
ret
ENDMODULE
MODULE ffirst
;
; "dos.h"
; ”ã­ªæ¨ï ffirst ¯à®¨§¢®¤¨â ¯®¨áª § ¤ ­­®£® ¢ pathname ä ©«  ¨§ £à㯯ë
; ä ©«®¢. €à£ã¬¥­â pathname ¬®¦¥â ᮤ¥à¦ âì ¨¬ï ¤¨áª  ¨ ª â «®£ ¤«ï ¯®¨áª .
; ‚ ¨¬¥­¨ ä ©«  ¤®¯ã᪠îâáï £«®¡ «ì­ë¥ ᨬ¢®«ë ? ¨ *. ˆ¬ï ­ ©¤¥­­®£® ä ©« 
; ­ å®¤¨âáï ¢ ä®à¬ â¥ DOS "filename.ext".
; ”ã­ªæ¨ï _ffirst ®â«¨ç ¥âáï ®â ä㭪樨 ffirst ⥬, çâ® ¢®§¢à é ¥â ¨¬ï
; ­ ©¤¥­­®£® ä ©«  ¢ ä®à¬ â¥ "FilenameExt".
; …᫨ ä ©« ®¡­ à㦥­, äã­ªæ¨ï § ¯®«­ï¥â áâàãªâãàã (®¯à¥¤¥«¥­­ãî ¢ "dos.h"),
; ­  ª®â®àãî 㪠§ë¢ ¥â  à£ã¬¥­â ffblk.
; €à£ã¬¥­â attr ᮤ¥à¦¨â  âਡãâ(ë) ä ©«®¢ ¤«ï ¯®¨áª  ¨ ¬®¦¥â ¯à¨­¨¬ âì
; á«¥¤ãî騥 §­ ç¥­¨ï, ®¯à¥¤¥«¥­­ë¥ ¢ "dos.h":
;
; FA_NORMAL Ž¡ëç­ë© ä ©«
; FA_RDONLY ’®«ìª® ç⥭¨¥
; FA_HIDDEN ‘ªàëâë© ä ©«
; FA_SYSTEM ‘¨á⥬­ë© ä ©«
; FA_LABEL Œ¥âª  ⮬ 
; FA_DIREC Š â «®£
; FA_ARCH €à娢­ë©
;
; Œo¦­o § ¤ ¢ âì ªà â­ë¥ §­ ç¥­¨ï  âਡã⮢, ¨á¯o«ì§ãï ᨬ¢o« "|"
; (®¯¥à â®à OR).
; ”ã­ªæ¨ï ¢®§¢à é ¥â 0 ¯à¨ ãᯥ譮¬ § ¢¥à襭¨¨ ¯®¨áª .
; …᫨ ä ©« ­¥ ­ ©¤¥­ ¨«¨ ¢ ¨¬¥­¨ ä ©«  ¢áâà¥â¨« áì ª ª ï-«¨¡® ®è¨¡ª ,
; ¢®§¢à é ¥âáï -1 ¨ errno ᮤ¥à¦¨â ­®¬¥à ®è¨¡ª¨.
;
; char ffirst(char *pathname, FIND *ffblk, char attr)
;
_ffirst_::
ld b,0 ; format "FilenameExt"
jr @1
ffirst_::
ld b,1 ; format "filename.ext"
@1: ld a,c ; attr
ld c,19h ; f_first
push ix
rst 10h
pop ix
ld (errno_##),a
ld a,0
ret nc
dec a
ret
ENDMODULE
MODULE fnext
;
; "dos.h"
; ”ã­ªæ¨ï ¯à®¨§¢®¤¨â ¯®¨áª á«¥¤ãî饣® ᮢ¯ ¤ î饣® ä ©« .
; ਠª ¦¤®¬ ¢ë§®¢¥, äã­ªæ¨ï ¢®§¢à é ¥â ®¤­® ¨¬ï ä ©« , ¤® â¥å ¯®à, ¯®ª 
; ¯ à ¬¥âàë ä ©«  ¡ã¤ãâ ¯®¤å®¤¨âì ¯®¤ § ¤ ­­ë¥ ¯ à ¬¥âàë ¯®¨áª .
; €à£ã¬¥­â ffblk ¤®«¦¥­ 㪠§ë¢ âì ­  áâàãªâãàã (®¯à¥¤¥«¥­­ãî ¢ "dos.h"),
; ¯à¥¤¢ à¨â¥«ì­® § ¯®«­¥­­ãî ä㭪樥© ffirst.
; ”ã­ªæ¨ï ¢®§¢à é ¥â 0 ¯à¨ ãᯥ譮¬ § ¢¥à襭¨¨ ¯®¨áª .
; …᫨ ä ©« ­¥ ­ ©¤¥­ ¨«¨ ¢ ¨¬¥­¨ ä ©«  ¢áâà¥â¨« áì ª ª ï-«¨¡® ®è¨¡ª ,
; ¢®§¢à é ¥âáï -1 ¨ errno ᮤ¥à¦¨â ­®¬¥à ®è¨¡ª¨.
;
; char fnext(FIND *ffblk)
;
fnext_::
ex de,hl
ld c,1Ah ; f_next
push ix
rst 10h
pop ix
ld (errno_##),a
ld a,0
ret nc
dec a
ret
ENDMODULE