Launch c program with parameters

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
User avatar
jacqu
Officer Cadet
Posts: 53
Joined: Sun Nov 27, 2022 4:42 pm
Location: Alsace, France
Contact:

Launch c program with parameters

Post by jacqu »

Hi!

Is there a way to launch a CC65 compiled program with parameters ?

For example, suppose I compiled a program called "ED" to edit some text file on the disk. If I want to call "ED" with a parameter giving the name of the text file to be loaded, like "ED README.TXT", is it possible to pass the parameter "README.TXT" to the program "ED" ?

If was thinking about using the basic "!" command, but I don't know how it could interact with a cc65 compiled program.

Thanks for your feedbacks,
Jacques
Old French Oric Atmos Nerd
User avatar
Dbug
Site Admin
Posts: 4522
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Launch c program with parameters

Post by Dbug »

As far as I know, neither SEDORIC or TDOS have a way to pass parameters to executables when they are launched.

That being said, I did a quick test using a comment after the command, and it seems to still be present in the command buffer in page zero.
image_2024-03-16_110350897.png
As you can see both my 'WHATEVER and 'DBUG TEST are still visible at offset $5A, I'm not sure these are guaranteed to be valid, but that could possibly be a way worth exploring: Launch whatever command you want, and have the parameters as a comment.

Now, does that work if a command is passed from a script or other program, no idea.
User avatar
jacqu
Officer Cadet
Posts: 53
Joined: Sun Nov 27, 2022 4:42 pm
Location: Alsace, France
Contact:

Re: Launch c program with parameters

Post by jacqu »

Thanks for the tip Dbug ! I'd never have thought of doing it that way.
Old French Oric Atmos Nerd
User avatar
ibisum
Wing Commander
Posts: 1666
Joined: Fri Apr 03, 2009 8:56 am
Location: Vienna, Austria
Contact:

Re: Launch c program with parameters

Post by ibisum »

jacqu, if you figure this out, perhaps we could do a C implementation that could be plonked into the OSDK, as well? Its something I've often thought about, but never considered there wouldn't be a std arg parser in the C lib ..
User avatar
jacqu
Officer Cadet
Posts: 53
Joined: Sun Nov 27, 2022 4:42 pm
Location: Alsace, France
Contact:

Re: Launch c program with parameters

Post by jacqu »

Hi ibisum,

Seems that I did not read the doc until the end:
IMG_0852.jpeg
CC65 already implements some main() function args parsing method based on the very same idea than Dbug’s one.

Though, Dbug’s approach of using ‘ instead of REM seems to be more compact and elegant.

I’m planning to write a wysiwyg text editor for Oric with encryption feature. With such an app, I might have finally found some serious usefulness for this old machine in 2024 (this does not mean that I don’t appreciate the fun part of the hobby. For example, I’m really looking forward to playing Dbug’s new game in gestation). I’m still in the early stages of this project and I’m still not sure how to handle safely the storage of the files on the disk.

I read this excellent article : https://www.idreamtin8bits.com/oric-scr ... o-the-oric
This made me grasp the great challenge of getting thorough disk errors handling, which is a prerequisite for my project. All tips on this topic will be warmly welcomed.
Old French Oric Atmos Nerd
User avatar
iss
Wing Commander
Posts: 1657
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Launch c program with parameters

Post by iss »

Hi, @jacqu!

Passing parameters to a program turned to be a real challenge!
Dbug's idea is the only way for an universal solution and (after lot hours :!: ) I have it working ! 8)

Reading CC65 docs is really helpful, take a look also in the sources of the CC65 standard library.
I need some time to polish the code and update my openOricLibrary - I hope to do it this week!

The problem is really very interesting for hacking, don't hesitate to dive into it.
So far I found 3 hidden traps!!! :lol:
User avatar
waskol
Flight Lieutenant
Posts: 415
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: Launch c program with parameters

Post by waskol »

May be I am wrong but I think there's no use to pass parameters to C program with an Oric. Just write your parameters in a specific memory area from the "calling program" and read them back from the c program. PEEK/POKE way (in ORIC.H) :
#define peek(a) mem[a]
#define deek(a) (* (int *)(mem+a))

#define poke(a,x) (mem[a]=(x))
#define doke(a,x) (* (int *)(mem+a) = (x))
Post Reply