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.
Z80 & 68k Assembly =>
z80 & ez80 Assembly
Author |
Message |
|
Jeffrey
Member
Joined: 12 Jun 2003 Posts: 212
|
Posted: 10 Nov 2003 08:02:17 pm Post subject: |
|
|
I have been posting more questions than answers lately, but...
How do I run an ASM program from an ASM program? I am trying to create a keyhook that will run a program when a certain key is hit. I dont need the source or explanation for the keyhook, just for running the program. If anyone has source, or has time to explain, please help! |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 10 Nov 2003 08:27:57 pm Post subject: |
|
|
Jeffery I'm not too sure you're ready for that kind of step. I'm glad you have extremely high aspirations though. I am more than willing to explain it if it is absolutely necessary. The biggest thing about it is you will be dealing with the Allocation and Deallocation of RAM. Luckily running a no-shell asm program is rather easy as compared to running an Ion one. |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 11 Nov 2003 02:03:41 pm Post subject: |
|
|
i assume you bcall(_InsertMem) then ldir the program to the new location, then some how "call" the program so that the ret simply returns to your program instead of the tios? or am i wrong? |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 11 Nov 2003 03:38:35 pm Post subject: |
|
|
Actually your guess is fairly accurate.
If you want to run an asm program from an asm program it gets a little complicated. As you have to remember there is already a program in userMem being executed. So you have to create a bunch of other offsets so data doesn't get overwrittin and cause a crash.
Fortunately in the case that Jeffery is doing we won't need to worry about it because the code will be executed by a keyhook.
Anyways Jeffery here's some code to put in your keyhook for executing a second program. Please note that I have not tested it. If there are any problems I will make mods later.
Lets assume the keyhook code will be executed in the AppBackUpScreen Buffer
Code: ;Whatever code/Keyhook start
keyhook:
add a,e
cp kprgm
jr z,AppBackUpScreen+(ExecutingProgram-keyhook)
ret
ExecutingProgram:
ld hl,AppBackUpScreen+(ProgramExecString-keyhook)
rst 20h
bcall(_ChkFindSym)
jr c,AppBackUpScreen+(Terminate_Program-keyhook)
ex de,hl
ld c,(hl)
inc hl
ld b,(hl)
inc hl
push hl;save pointer to start of program data
push bc;push bc to the stack to save size of program
pop hl;place size into hl
push hl;save again yet size is still in hl
ld de,userMem-2
bcall(_InsertMem);allocate however many bytes it in hl
pop bc;size into bc for ldir
pop hl;Start of program Data=hl
ld de,userMem-2
push bc;save size again
ldir;copy program to userMem-2
call Usermem;by calling userMem we skip the AsmPrgm token
;once the program is done execution is returned here
ld hl,userMem-2
pop de;pop size to deallocate
bcall(_DelMem)
xor a
ret
Terminate_Program:
xor a
ret
ProgramExecString:
.db ProgObj,"PROGRAM",0
Please note that this code is based on the fact that the program will already be in RAM. If it isn't then the calc will crash.
Last edited by Guest on 11 Nov 2003 03:40:27 pm; edited 1 time in total |
|
Back to top |
|
|
Jeffrey
Member
Joined: 12 Jun 2003 Posts: 212
|
Posted: 11 Nov 2003 04:13:26 pm Post subject: |
|
|
Ok ,I will test it now. Thanks, you have earned your name in the credits!!! |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 11 Nov 2003 05:11:34 pm Post subject: |
|
|
There's a bug somewhere in the code. I tested it and it crashed, I will try and find the problem. |
|
Back to top |
|
|
Jeffrey
Member
Joined: 12 Jun 2003 Posts: 212
|
Posted: 11 Nov 2003 07:27:32 pm Post subject: |
|
|
Yeah. Now I am trying to look for an alternative to the execution idea! |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 12 Nov 2003 09:13:18 am Post subject: |
|
|
if you use an external program and the program has been renamed,etc., you might have a problem
if you know what the program will be, cant you just put the program as part of your code? or is the program user-defined? |
|
Back to top |
|
|
Jeffrey
Member
Joined: 12 Jun 2003 Posts: 212
|
Posted: 12 Nov 2003 11:05:46 am Post subject: |
|
|
I have a better idea, I will just change it to application format. That way I can use the keyhooks more effectively. Only now I will have to learn what is different in applications than RAM programs. |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 13 Nov 2003 08:56:18 am Post subject: |
|
|
also, jwales, could you not just .org appbackupscreen instead of doing all the appbackupscreen+(excutinprogram.... stuff?
or does the .org command do something else for TASM? |
|
Back to top |
|
|
|
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