OPEN and RUN program

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

OPEN and RUN program

Post by unartic »

I want to build somethhing like a ms-dos shell.

So when my program is running, I want to be able to load another program into memory and then run that program.

I have this in mind:

- My program loads a small program into memory, lets say $9000 (tsr)
- I jump to $9000 to start executing this program.
- This program loads the program I actualy want to run into memory at $8001 ("LOAD"X.PRG")
- I jsr to $8001 to start executing.
- When this program normaly returns to basic, it returns to the program in the $9000 location, which then loads my main program in $8001 and start executing it again
- I'll manipulate a byte string in the $9000 program to hold the program it needs to load and run.
- To start de $9000-tsr programI actualy jmp to $9019 as it seems the programs first opcodes are stored there
- To start de $8001-program I jsr to $8013 as it seems that is the start of that program.

I hope the above is clear enough ;-)

I'm able to load the programs in de desired memory locations. However the jumps and jsr do work partialy. I verified the tsr-program runs correctly at that memoryt location via debug mode.

I think my knowledge about the header of prg-files is to basic.

Any thoughts?
User avatar
AndyMt
Posts: 326
Joined: Sun Jun 21, 2020 3:02 pm
Location: Switzerland

Re: OPEN and RUN program

Post by AndyMt »

There is a solution which works without a tsr program:
https://www.commanderx16.com/forum/view ... 869#p29869
unartic
Posts: 145
Joined: Sat Oct 28, 2023 3:26 pm

Re: OPEN and RUN program

Post by unartic »

Nice trick.

However, I'm unable to find a way to put the CR on the keyboard buffer.

Any thoughts?
User avatar
AndyMt
Posts: 326
Joined: Sun Jun 21, 2020 3:02 pm
Location: Switzerland

Re: OPEN and RUN program

Post by AndyMt »

Kernal function $FEC3
kbdbuf_put
Keycode $0D I think
Post Reply