This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
tiuser1010


Member


Joined: 23 Apr 2009
Posts: 100

Posted: 27 Jun 2009 10:00:01 pm    Post subject:

I ve got a quick question about this rom call. If you use it in a program will the calc use memory from both programs

what i mean by that is if the program that has the bcall ParseInp is 3K and the program its running is 2K when the first program gets to the point of executing the second one is the calc now using 5K of its availble ram to run them or will it run the second program complely independent of the first one and after it done contine to run the first one


Last edited by Guest on 28 Jun 2009 08:30:13 pm; edited 1 time in total
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 04 Jul 2009 03:25:17 pm    Post subject:

ParseInp is used to run BASIC programs, not assembly programs. The OS doesn't need to copy or move a BASIC program in order to run it. So no, running a 2-kilobyte BASIC program doesn't require 2 additional kilobytes of RAM, because the BASIC program must already exist in RAM; those 2 kilobytes have already been allocated.

Running one assembly program from another is a completely different story.
Back to top
tiuser1010


Member


Joined: 23 Apr 2009
Posts: 100

Posted: 10 Jul 2009 12:11:45 am    Post subject:

So how do you run assembly programs
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 10 Jul 2009 11:29:19 pm    Post subject:

That's a hard question. What you're asking, essentially, is "how do you write a shell?" And the best answer is to look at the shells that have already been written.

As you probably know, there are many different types of assembly programs, which are intended to be run in very different ways. TIOS assembly programs are run by inserting a block of memory at userMem and then copying the code there; shell programs are generally run by moving them to the start of user memory. Many shell programs rely on the shell's libraries: Ion programs will expect to find a jump table at cmdShadow + 80, while MirageOS and DoorsCS programs expect to find a jump table at 4080. Most, if not all, shell programs are not allowed to touch the data in cmdShadow, so you can use that area for your program loader (as Ion itself does); TIOS assembly programs, in contrast, have no limits to the RAM areas they may use. TIOS assembly programs may use GetKey, may play with the app context vectors, and may throw errors.

There's actually a B_CALL somewhere (I don't remember the details; look on WikiTI) that runs an assembly program as Asm( does. Obviously, it has the same limitations. I have no idea if it is safe to use that routine within another TIOS assembly program. It's a fair bet that it is not safe to do so within a shell program.

MirageOS provides a 'runprog' function for the use of external GUIs. I don't know how safe that routine is to use within other programs.

Now, if you're not actually interested in running arbitrary assembly programs provided by the user, but rather, you simply want to break up your own program into several separate files, that makes things a bit simpler, because you can impose restrictions on yourself (don't use Ion libraries, don't touch cmdShadow, don't allow any TIOS errors to be thrown, and so forth.) Your program loader can be as simple or as complex as you want, provided that you always clean up properly and leave memory the way you found it.
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 12 Jul 2009 11:21:41 am    Post subject:

tiuser1010 wrote:
So how do you run assembly programs

There's no way to simply run an arbitrary assembly program from within another arbitrary assembly program. When the TI-OS runs an asm program, the code is transferred to $9D93, so if you tried to do the equivalent of Asm( from within an asm program, that program's code would be overridden. The reason for this is that during assembly any label names (like those used in jumps or calls) are substituted for their addresses, which are determined by assuming the program will be run at $9D95.
Back to top
magicdanw
pcGuru()


Calc Guru


Joined: 14 Feb 2007
Posts: 1110

Posted: 15 Jul 2009 12:11:17 am    Post subject:

simplethinker wrote:
There's no way to simply run an arbitrary assembly program from within another arbitrary assembly program. When the TI-OS runs an asm program, the code is transferred to $9D93, so if you tried to do the equivalent of Asm( from within an asm program, that program's code would be overridden. The reason for this is that during assembly any label names (like those used in jumps or calls) are substituted for their addresses, which are determined by assuming the program will be run at $9D95.
Nah, think of it like this. There is a "stack" of sorts with the top at $9D95 and the base at the end of user ram. Now, when you run program number one, it is moved (or copied) to $9D95, pushing everything in user ram down. When program one calls program two, it does the same thing, pushing program one down as well. Program two will have the correct alignment to run, and program one won't, but that's fine because only program two is running code at the moment! When program two is done, it will be unloaded, program one is moved back to $9D95, and execution continues from before.
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 15 Jul 2009 12:53:00 pm    Post subject:

... Which is not, in the general case, a safe thing to do.

Here are the possible cases:

An Ion program cannot run a TIOS program, because of GetKey and error handling issues, and there's nowhere safe to put a program loader.
An Ion program could in theory run an "Ion+TIOS" program, by backing up cmdShadow and placing its own program loader there.
Likewise, an Ion program could in theory run a normal Ion program by providing its own libraries.
An Ion program cannot run a MirageOS program; you need an app for that. If you have MirageOS present, you might be able to fake it, but it would be very risky (you'd need to set up cmdShadow exactly as MirageOS expects to find it.)
An Ion program cannot run a Flash application.

A MirageOS program cannot run a TIOS program, for the same reasons an Ion program can't.
A MirageOS program could probably run another MirageOS, Ion, or Ion+TIOS program, using runprog. (You might have to back up some or all of cmdShadow as well - I don't know.)
A MirageOS program cannot run a Flash application.

A TIOS program might be able to run another TIOS program; it would require a careful analysis of the B_CALL I mentioned.
A TIOS program can run an Ion or Ion+TIOS program. Ion does.
A TIOS program cannot run a MirageOS program, for the same reasons an Ion program can't.
A TIOS program can (I think) safely start a Flash application, but you can't get control back when the app quits.

A Flash application can easily run TIOS, Ion, and MirageOS programs.
A Flash application can start another application; using hooks, you can try to get control back when the app quits (it won't always work in the general case.)
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement