GemDos $4B (EXEC) - Having Problems

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
User avatar
mrdalliard
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 104
Joined: Tue May 01, 2012 8:29 pm
Location: UK
Contact:

GemDos $4B (EXEC) - Having Problems

Post by mrdalliard »

Hi,

So I'm a complete n00b when it comes to learning asm, but I've made some progress so far and it's been OK. However, I want my program to call another program - hence where (I hope) the subject of this comes in.

My code virtually replicataes what's in the bible, ST Internals, with the exception that I've changed the program name and it doesn't appear to be doing what I expected, namely calling 'program.prg'.
MOVE.L #env,-(SP)
MOVE.L #com,-(SP)
MOVE.L #fil,-(SP)
MOVE.W #0,-(SP)
MOVE.W #$4B,-(SP)
TRAP #1
ADD.L #14,SP

...
...

fil: dc.b "program.prg",0
com: dc.b 0
env: dc.b 0
(Apologies for formatting, I've pasted this in)

Having gone through debug. it looks like the code runs, but nothing appears to happen. The code continues executing and the called program doesn't kick off. What am I doing wrong?

Thanks,

M.
--
My STOS demo, "Better Late Than Never" is here! Details at https://dalliard.net/
520 STFM Owner since 1988.
czietz
Hardware Guru
Hardware Guru
Posts: 2450
Joined: Tue May 24, 2016 6:47 pm

Re: GemDos $4B (EXEC) - Having Problems

Post by czietz »

What is the return code of Pexec? It's in D0 after the TRAP.

Do you leave enough free memory for TOS to run another program? I.e., does your program Mshrink its own TPA before trying to Pexec?
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3616
Joined: Sun Jul 31, 2011 1:11 pm

Re: GemDos $4B (EXEC) - Having Problems

Post by Eero Tamminen »

And if that does not help, you can use Hatari with EmuTOS (1024k version), load EmuTOS symbols to debugger ("symbols etos1024k.img"), and see [1] what exactly TOS does with your call.

[1] e.g. with "--trace cpu_symbols" (prefix with "setopt" common if doing that from Hatari debugger instead of command line), and checking the code with for the listed functions from EmuTOS sources.
User avatar
Zorro 2
Administrator
Administrator
Posts: 2301
Joined: Tue May 21, 2002 12:44 pm
Location: Grenoble (38) - France
Contact:

Re: GemDos $4B (EXEC) - Having Problems

Post by Zorro 2 »

Hi! Can you give your stuff to see what happen please ?
.~^ Member of NoExtra Team :: Member of HMD :: Pouet :: DemoZoo :: GitHub ^~.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2955
Joined: Sun Aug 03, 2014 5:54 pm

Re: GemDos $4B (EXEC) - Having Problems

Post by ThorstenOtto »

First thing you should do to check the return value of the Pexec() call. If that is a negative GEMDOS error code, that should give you already a clue what is going wrong.

Most likely errors:
- You did not Mshrink() your TPA (as already mentioned above). In that case, all memory is still assigned to your program, and GEMDOS simple does not have memory to execute another one.
- The 'program.prg' that you are trying to execute is not in the same directory as your program.
- The 'program.prg' is not a valid GEMDOS executable.

Another note: using

Code: Select all

MOVE.L #env,-(SP)
will pass an empty environment to program.prg. Typically, you want to pass your own environment along, which you can achieve by using

Code: Select all

clr.l -(SP)
instead.
User avatar
mfro
Atari God
Atari God
Posts: 1242
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GemDos $4B (EXEC) - Having Problems

Post by mfro »

... one other thing (not related to your problem, probably, so it will just bite you later) is that you are pushing 16 bytes to the stack but - on return from the GEMDOS trap - correct only 14.
User avatar
thomas3
Captain Atari
Captain Atari
Posts: 350
Joined: Tue Apr 11, 2017 8:57 pm

Re: GemDos $4B (EXEC) - Having Problems

Post by thomas3 »

Hi,

I'm assuming the op is trying to load and execute a compiled STOS .prg - I'm therefore 99.99% sure that the issue is the absent mshrink :)
User avatar
mrdalliard
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 104
Joined: Tue May 01, 2012 8:29 pm
Location: UK
Contact:

Re: GemDos $4B (EXEC) - Having Problems

Post by mrdalliard »

Hi, thanks for replying everyone. In answer to some questions:
  • Program to be called is present and is in the same folder as the assembled object
  • [D0 = "FFFFFFDF" upon completion of GEMDOS call.
  • Thomas3 is right, I'm calling a STOS program. :)
I've not tried adding the MSHRINK section in before the call, so will give that a go.

Cheers,

M.
--
My STOS demo, "Better Late Than Never" is here! Details at https://dalliard.net/
520 STFM Owner since 1988.
User avatar
mrdalliard
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 104
Joined: Tue May 01, 2012 8:29 pm
Location: UK
Contact:

Re: GemDos $4B (EXEC) - Having Problems

Post by mrdalliard »

mfro wrote: Wed Feb 21, 2024 9:34 am ... one other thing (not related to your problem, probably, so it will just bite you later) is that you are pushing 16 bytes to the stack but - on return from the GEMDOS trap - correct only 14.
Thanks for spotting this!
--
My STOS demo, "Better Late Than Never" is here! Details at https://dalliard.net/
520 STFM Owner since 1988.
User avatar
mrdalliard
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 104
Joined: Tue May 01, 2012 8:29 pm
Location: UK
Contact:

Re: GemDos $4B (EXEC) - Having Problems

Post by mrdalliard »

czietz wrote: Tue Feb 20, 2024 9:34 pm Do you leave enough free memory for TOS to run another program? I.e., does your program Mshrink its own TPA before trying to Pexec?
Hi, this was indeed the solution. Thanks!

I've now got three bombs going on somewhere else, as the program completes..... I might get the hang of this eventually! :wink:

Cheers,

M.
--
My STOS demo, "Better Late Than Never" is here! Details at https://dalliard.net/
520 STFM Owner since 1988.
User avatar
mrdalliard
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 104
Joined: Tue May 01, 2012 8:29 pm
Location: UK
Contact:

Re: GemDos $4B (EXEC) - Having Problems

Post by mrdalliard »

Just a thought - when the program is completed and control has been passed back to the original, does the memory need to be "unshrunk" again?

Cheers,

M.
--
My STOS demo, "Better Late Than Never" is here! Details at https://dalliard.net/
520 STFM Owner since 1988.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2955
Joined: Sun Aug 03, 2014 5:54 pm

Re: GemDos $4B (EXEC) - Having Problems

Post by ThorstenOtto »

mrdalliard wrote: Wed Feb 21, 2024 2:13 pm D0 = "FFFFFFDF" upon completion of GEMDOS call.
That is -33, which is the error code for "file not found".
Post Reply

Return to “680x0”