Post Reply 
How do I create a Subroutine using System RPL?
09-30-2022, 03:55 PM
Post: #11
RE: How do I create a Subroutine using System RPL?
(09-30-2022 02:24 PM)wmundstock Wrote:  My understanding is that right after the CK&DISPATCH1 we add the types we want to check. If its real real it should be #00011 so this mean we can only test up to 5 arguments for their type?

What if we had a CKNNOLASTWD with N=10? Would I create a loop to check each parameter individually?

The standard dispatch mechanism supports checking up to 5 arguments. As you've noted, there is the "CKN..." structure, but that is most useful when you've got a number in stack level 1 that is indicating a count of things to operate on (the example of DROPN is a good one to describe that situation).

If you need to check more than 5 arguments, you have to do it a different way. The SysRPL DEPTH code word can be useful (after a preliminary check for the first 5 using standard commands). It's possible to "stack" the dispatch calls (CK&DISPATCH1), but you shouldn't try to stack CK5NOLASTWD with the other "counting" checks (CK<1..5>NOLASTWD).

This all becomes rather messy, and I would actually recommend that you reconsider whether passing that many arguments on the stack is the best approach. If you really need that many arguments, it's probably better to pass them in list form to the program. That allows you to use the standard count/dispatch mechanism, but then requires that you do a manual check of the number of elements in the list and their types. That's not so difficult, really, and I would suggest that the code would look more organized if you went that route instead.

(09-30-2022 02:24 PM)wmundstock Wrote:  I tried using the directory macro as you suggested. Does that only work if in one single file? I tried creating 2 files and assignign a section like below, but it did not work.
...
After moving both Assembles into one file it worked.

You answered your own question here. Smile The objects you're creating need to appear to the compiler as if they are all in 1 file due to the way DirMacro works. This can be done one of two ways:
  1. The objects being defined need to all be in one source code file. This is essentially what you did above.
  2. The object definition source can be in separate files, but there would still need to be a single file that brings them all together with INCLUDE compiler directives for each separate source file.
Imagine you have 3 separate source files containing definitions for 1 object each:

file: object1.s
Code:
ASSEMBLE
   Dir <ob1>
RPL
::
   % 123
;

file: object2.s
Code:
ASSEMBLE
   Dir <ob2>
RPL
::
   % 456
;

file: object3.s
Code:
ASSEMBLE
   Dir <ob3>
RPL
::
   % 789
;

To compile these into a directory object that has all three, you would then need to have a "master directory" source file that has something like the following:
Code:
RPL

INCLUDE DirMacro.s

( object 1 )
INCLUDE object1.s

( object 2 )
INCLUDE object2.s

( object 3 )
INCLUDE object3.s

Note that the INCLUDE for the DirMacro only exists in the "top level" file. There should only be 1 INCLUDE for that macro in the hierarchy.

Hope this helps!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How do I create a Subroutine using System RPL? - DavidM - 09-30-2022 03:55 PM



User(s) browsing this thread: 2 Guest(s)