Login
Back to forumReply to this topicGo to last reply

Posted By

soft-ice
on 2020-12-12
06:00:59
 Calling 'RUN' from Machine Code

Hi all,

Does one of you know how to call 'RUN' from machine code? You would think it is as simple as "JMP $8BBC" or "JSR $8BBC", but unfortunately this issues a "UNDEF'D STATEMENT ERROR". Also doing a "SYS 35772" instead of "RUN" gives the same problem.

Possibly some constants need to be set first?

Thanks for you advice.

Best,
"Soft-ice"

Posted By

Basman
on 2020-12-12
13:09:41
 Re: Calling 'RUN' from Machine Code

Hello, I'm using:

CLI
JMP $8bdc

Also, see if you need to alter the Basic pointers beforehand.

Posted By

Csabo
on 2020-12-12
17:04:22
 Re: Calling 'RUN' from Machine Code

It can be a little hard to find, but we do have this exact piece of info in our Knowledge Base happy Here it is!

RUN Command

From that page:

Machine Language
To perform the equivalent of the RUN command, use this code:
JSR $8BBE
JMP $8BDC

As Basman mentioned, the BASIC pointers ($2B/$2C) have to be set (they have to point to a valid BASIC program).

Posted By

Soft-ice
on 2020-12-12
17:46:04
 Re: Calling 'RUN' from Machine Code

Thanks to you both!

Posted By

Soft-ice
on 2020-12-13
05:38:21
 Re: Calling 'RUN' from Machine Code

It works now! Thanks.

Out of curiosity: Any idea why it is so that JMP $8bbc does not work? After all, the "RUN" command links to 8bbc, so naively I would think that sys dec("8bbc") is equivalent to "RUN"? What is the reason that it does not work?

Soft-ice

Posted By

Csabo
on 2020-12-13
07:22:21
 Re: Calling 'RUN' from Machine Code

It's true that the jump table for the RUN BASIC command ends up at $8BBC. However, if you check the ROM at that location, you can see that it starts with a BNE. That branch only works (or makes sense) when it's the BASIC interpreter that goes there.

These two calls "simulate" what should happen, the branch does not occur (so we end up on $8BBE, that's what the first JSR is), and so on.

Posted By

soft-ice
on 2020-12-13
07:36:12
 Re: Calling 'RUN' from Machine Code

Thanks for the clarification! Very helpful.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024