Hacker's Edge Game Guide: Programming/Example program: fexists.asm

Example program: fexists.asm
July 27, 2016

In this example we go through the File I/O API to demonstrate how we can check if a file exists on the host's file system. Be sure your running the latest KERNEL and have the FILEIO.SYS driver properly installed on your host or this example won't work.

.INC kernel.inc
JSR %finit
LDA $f6
STA $fd
LDA $f5
STA $fc
JSR %fexists
LDA $ff
BNE ne
LDY #equal
JSR %print
BRA end
LDY #noteq
JSR %print

DCS File found.\n\0
DCS File not found.\n\0

After assembling you can run it at the command-line using the following: fexists.bin KERNEL.SYS