Change directory - assembler

All aspects of programming on the Commander X16.
Post Reply
unartic
Posts: 145
Joined: Sat Oct 28, 2023 3:26 pm

Change directory - assembler

Post by unartic »

Hi!

Being a highlevel programmer for several decades (started in the dos-ara) I'm now commited to learn assembly and x16 seems to be a great platform to do it on.

I'm using ca65.

I'm trying some 'random' basic stuff to get a feeling.

With SETLFS, SETNAM and LOAD using "$" as the filename, I'm able to load the filelist of the current directory.

Now I want to change the directory to a subdirectory and load a filelist from that directory. After some extensive googling, I'm not able to find it, so I hope somone can help me out here :-)
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Change directory - assembler

Post by desertfish »

https://github.com/X16Community/x16-doc ... nd-channel

use the command channel (15) to send the command "CD:<directory>"
unartic
Posts: 145
Joined: Sat Oct 28, 2023 3:26 pm

Re: Change directory - assembler

Post by unartic »

Thanks! That was the missing link.

I now have this, but it doesn't work. Can you point me in the right direction?:
.org $080D
.segment "ONCE"

LOAD     = $FFD5
CLOSE    = $FFC3
SETLFS   = $FFBA
SETNAM   = $FFBD

jmp start


DOS_COMMAND: .byte "CD://DIR1/DIR2"
END_DOS_COMMAND:

tbuffer: .res 20000, $41

start:
   lda #2   ; Logical Number
   ldx #8   ; device
   ldy #15  ; control channel
   jsr SETLFS
   
   lda #(END_DOS_COMMAND-DOS_COMMAND) ; command length
   ldx #<DOS_COMMAND
   ldy #>DOS_COMMAND
   jsr SETNAM
   
   lda #0   ; load
   ldx #<tbuffer  ;don't know why this is needed for the command channel
   ldy #>tbuffer
   
   jsr LOAD
   
   lda #2
   jsr CLOSE 
  
    
rts
Stefan
Posts: 465
Joined: Thu Aug 20, 2020 8:59 am

Re: Change directory - assembler

Post by Stefan »

I think you must use Kernal function OPEN, not LOAD.

The command gets executed, and then you may read the drive response from the opened file sequentially.

This is done by first setting the file as input with CHKIN and then read one char/byte at a time with CHRIN.

You need to clean up this when done with CLRCHN and CLOSE.
Post Reply