I need some help to find out how to archive/unarchive a basic program with an ASM program. I also need help to find out how to run a Basic program from an ASM program.
Archiving and unarchiving is easy.


Code:
    ld hl,BasicProgName
    rst 20h
    bcall(_arc_unarc)
    ...
    ret
BasicProgName:
    .db 5,"PROG",0


Ideally you should also toss some error-checking in there to make sure the program actually exists.
KermMartian wrote:
Archiving and unarchiving is easy.


Code:
    ld hl,BasicProgName
    rst 20h
    bcall(_arc_unarc)
    ...
    ret
BasicProgName:
    .db 5,"PROG",0


Ideally you should also toss some error-checking in there to make sure the program actually exists.


Thanks. But how do I run a Basic program and at the same time terminate the Asm Program.
Ooooh, that's tricky. You can kinda do it, but you're supposed to return to the ASM program to clean up after the BASIC program. I just looked through the source code for Doors CS's BASIC execution routines, and it's a real mess. I'll try to sort through it for you, but I don't think you're going to be able to do exactly what you want to do.
When a program runs from the homescreen, the OS allocates memory for it and stores the size of your program to asm_prgm_size (89ECh). When your program returns, it returns to a piece of the OS that calls _DelMem on exactly that size from userMem (9D95h, where your program runs from).

You can copy a small loader to saferam which deletes yourself. When you jump there and delete yourself, you're now no longer taking up any user RAM (which is the source of RAM leaks). You just happen to have control at the moment, and you can return control to the OS by BJUMPing to _JForceCmdNoChar, just like a Flash application. At this point, you can run a BASIC program with _ParseInp (program name and type in OP1) and then jump to the homescreen. I would use a saferam area that the OS will never touch, such as appBackUpScreen (at least it's very unlikely that it will), so that anything the BASIC program does won't make the calculator unstable.

You might want to set donePrgm,(iy+doneFlags) if it's not already set (EDIT: or reset numOP1,(iy+ParsFlags2)), so it'll display "Done" once the BASIC program returns and it'll look like normal. _JForceCmdNoChar itself might force that to be reset, I'm not sure. I'm sure there's some way to trigger it...if nothing else, you can call _dispDone yourself and then _JForceCmdNoChar.

This all theoretical, I haven't tried any of this of course. Smile But you can delete yourself and jump to _JForceCmdNoChar just fine (this is the preferred thing to do if you're screwing around with Input/Prompt or some other edit buffer from a RAM program, so that there's no chance of RAM leaks), and BASIC programs run with _ParseInp. Hope that helps.

EDIT: if you want to be super nasty and make some assumptions about the structure of the OS (which is pretty safe these days...updates are few and far between), you can eliminate the need for a saferam area by looking up the address of _JForceCmdNoChar from the jump table on page 1Bh/3Bh/7Bh, which will be on page 0 (which is good), which means you can push that address onto the stack and then BJUMP instead of BCALL to _ParseInp. That'll cause the OS to do _ParseInp and then return back into _JForceCmdNoChar. At least that's the theory...haven't tried that either.

I'm sure that's more than you ever wanted to know, but once I get going...
I just realized that the ASM program don't need to be terminated... Found a way around. What I plan to make is this

1. The starter is a basic program. It executes and end with sotring an ID in one of the variables (defining what program it was called from and what program to be run) and run the ASM program.

2. The ASM program reads the ID, unarchives and run the Basic program defined in the ID.

3. When the Basic program ends or need to call another Basic program, it stores a new ID and returns to the ASM program.

4. The ASM program reads the new ID and determine what to do out from it (archive program that just ended, unarchive and run the program called or return to the starter BASIC program [where it is no code left and the program stops and return to the operating system]).

*Edit*
But how do I read a Basic one-letter variable and what format is it in then?
  
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