Login
Back to forumReply to this topicGo to last reply

Posted By

SVS
on 2004-05-18
05:35:55
 SYS command

I need to execute a SYS command that does not refere a Kernal routine, but an user routine appended to the Basic program. Due the great size of the Basic program, the ML routine to be run by SYS is allocated over $8000, then in the RAM area under the ROM. How can I obtain that SYS will not read/execute the code of ROM?

PS. - Any comment will be welcome, please reply your idea! I write this because recently I see that "programming" posts are empty and with no reply. I'm sad for this. Keep +4 programming (not only collecting)! happy

Posted By

Csabo
on 2004-05-18
08:46:26
 Re: SYS command

If you just need one routine, place it to $7FFC, that will leave 4 bytes for SEI/STA $FF3F, so that the routine can start. happy

Otherwise, write a small routine and copy it anywhere in the lower memory, something like: SEI, STA $FF3F, JSR $XXXX, STA $FF3E, CLI, RTS. Then each time you need to call a routine above $8000, you would POKE addr + 5, LO : POKE addr + 6, HI : SYS addr.

ps. the XAA topic was about programming, and generated some nice feedback wink

Posted By

Csabo
on 2004-05-18
09:35:48
 Re: SYS command

I just thought of something else. You can solve this problem by avoiding it completely. Let's say you need 8 Kb's worth of machine code: start the basic program from $3000, and write the code before it. No conflict! Also, when you would call your routines, sometimes you will save one byte, because the SYS address can be 4 digits instead of 5 wink

Posted By

SVS
on 2004-05-18
11:02:19
 Re: SYS command

Thank you Csabo for the replies.
Unfortunately the solutions you tip are not for my case
In fact my situation is:
a) I have to wedge (by the SYS) already existing programs
b) The location of ML routine is variable and is calculated time by time, because the original prg could have any size
c) The original program *can be* greater than $7000 then it could (or not) go beyond the $8000 border, where RAM and ROM are overput
d) The programs start with a little part of BASIC, but then it enclose much ML code, then not relocable. This means that I cannot move the whole original program.

Hoping you are not angry, I sure you these are not jokes, but real things. Yesterday evening I studied on my Plus4 books (and on Plus4 Programmer Guide (thanx James!), but without solution...

Quiz: what is the programs to be wedged? happy happy

Thank you pals

Posted By

Csabo
on 2004-05-19
14:34:42
 Re: SYS command

Without actually seeing the exact problem, I see only one way to go about this. Bottom line: you cannot start machine language code with a simple SYS, if it's located above $8000. You can, however, use a small caller-routine (like the one I described above), which will essentially be two POKEs and one SYS every time you need to call a routine. It will work every time, regardless of the location of the code. That's what I would do, the things you mentioned above are no problems if you use this method.

Posted By

JamesC
on 2004-05-20
21:46:23
 Re: SYS command

How about using a REM stetement to hold machine code?

10 rem xxxxxxxx (enough x's to hold the machine code)
20 for x=4102 to 4110 : read a : poke x,a : next
30 data 1,2,3,4,5,6,7,8,9 (actual machine code in decimal would be placed here, I am just setting up an example here)

Run the program, then delete lines 20 and 30. Save to disk for safekeeping, then append your existing program onto this line.

Now your program can poke the desired jump-to address to the proper place in line 10 to make the jump valid in machine language. You have a known place to SYS to (SYS4102).

This is modified from Transactor Volume 6, Issue 5, Bits and Pieces column.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon