How would I go about executing a separate program from a C program?
I know that it would overwrite all of the memory currently used by C, but there are ways around that if there is a way of smoothly transitioning to the new program.
My current idea would be to copy the entire new program to the correct address followed by some custom code to copy my program back afterwards and then run that.
That seems in theory like it would work, but how would I go about actually doing it?

P.S. Sorry if I seem like I am being ignorant, but I can't seem to find any good explanation as to why this couldn't be done.
Are you wanting to make a shell? You can always look at the CEsium src on github to see how it does it?
tr1p1ea wrote:
You can always look at the CEsium src on github to see how it does it?

I would, but I SUCK at figuring out what ASM does, especially with the amount of custom subroutines and labels used in Cesium.
Cesium works by being an app. Unless you also want to be an app, which isn't really possible when writing C, you'll have to use another method.

This code might be more helpful: https://github.com/beckadamtheinventor/BOSshellCE/blob/master/src/asm/runprgm.asm
commandblockguy wrote:
Cesium works by being an app. Unless you also want to be an app, which isn't really possible when writing C, you'll have to use another method.

This code might be more helpful: https://github.com/beckadamtheinventor/BOSshellCE/blob/master/src/asm/runprgm.asm


Replace the string "BOSSHELL" with the name of your program, assemble the code using fasmg, insert the hex string into your program, copy the data to address 0xE30800 (Which it assembles to run at), which can then be executed with the ICE code:

Code:

Asm(C30008E3

Side note: this routine will not return to your program where you call it. It will restart your program from the beginning.
beckadamtheinventor wrote:
commandblockguy wrote:
Cesium works by being an app. Unless you also want to be an app, which isn't really possible when writing C, you'll have to use another method.

This code might be more helpful: https://github.com/beckadamtheinventor/BOSshellCE/blob/master/src/asm/runprgm.asm


Replace the string "BOSSHELL" with the name of your program, assemble the code using fasmg, insert the hex string into your program, copy the data to address 0xE30800 (Which it assembles to run at), which can then be executed with the ICE code:

Code:

Asm(C30008E3

Side note: this routine will not return to your program where you call it. It will restart your program from the beginning.

How would I go about calling this routine from C, while passing it the name of/pointer to the program like a function?

EDIT:
What I mean, to be a bit more clear, is:
    1) What ASM variable/memory address does this routine read the name of/pointer to the program from? (OP1?), and
    2) How would I go about setting that variable from C?
calclover2514 wrote:
beckadamtheinventor wrote:
commandblockguy wrote:
Cesium works by being an app. Unless you also want to be an app, which isn't really possible when writing C, you'll have to use another method.

This code might be more helpful: https://github.com/beckadamtheinventor/BOSshellCE/blob/master/src/asm/runprgm.asm


Replace the string "BOSSHELL" with the name of your program, assemble the code using fasmg, insert the hex string into your program, copy the data to address 0xE30800 (Which it assembles to run at), which can then be executed with the ICE code:

Code:

Asm(C30008E3

Side note: this routine will not return to your program where you call it. It will restart your program from the beginning.

How would I go about calling this routine from C, while passing it the name of/pointer to the program like a function?

EDIT:
What I mean, to be a bit more clear, is:
    1) What ASM variable/memory address does this routine read the name of/pointer to the program from? (OP1?), and
    2) How would I go about setting that variable from C?



Code:

typedef struct __var_t__{
  uint8_t type;
  char name[8];
}var_t;

const var_t variable = {
  0x06, //protected program
  "PROGRAM",0 //program name
}
memcpy((void*)0xE30900,&variable,9);


The struct isn't necessary, I just added it to make the data format clear.
Thank you so much. This will REALLY help me.

I do have one more question:
What are the possible values for the variable "type"? (If 0x06 means "protected PRGM", what's 0x05, if it is anything at all?)
The types are the same as the fileioc types, so you can use TI_PPRGM_TYPE instead of 0x6. TI_PRGM_TYPE is 0x5, which I guess makes sense, as it's 1 less than protected programs.

You probably don't want to use other types here, as generally, only protected programs contain assembly (though I guess an extremely well-crafted list or string might be executable as well).

You can find a more complete list of file types in the tivars_lib_cpp source.
commandblockguy wrote:
The types are the same as the fileioc types, so you can use TI_PPRGM_TYPE instead of 0x6. TI_PRGM_TYPE is 0x5, which I guess makes sense, as it's 1 less than protected programs.

You probably don't want to use other types here, as generally, only protected programs contain assembly (though I guess an extremely well-crafted list or string might be executable as well).

You can find a more complete list of file types in the tivars_lib_cpp source.

Thanks. That's exactly what I needed. Smile
On the libtifiles side, the equivalent tables are in
https://github.com/debrouxl/tilibs/blob/experimental2/libtifiles/trunk/src/types83p.cc
https://github.com/debrouxl/tilibs/blob/experimental2/libtifiles/trunk/src/typesoldz80.cc
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement