Skip to content

[Feature Request] ORGIN directive #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GSoftwareDevelopment opened this issue Sep 13, 2023 · 1 comment
Open

[Feature Request] ORGIN directive #119

GSoftwareDevelopment opened this issue Sep 13, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@GSoftwareDevelopment
Copy link
Contributor

GSoftwareDevelopment commented Sep 13, 2023

It would be nice to be able to specify from the source code level for procedures where they should be compiled. I see my proposal as follows.

  1. via the function/procedure modifier Origin xxxx, where xxxx, would be the address in memory.
procedure myProc(); Origin $2000;
Begin
End;
  1. via a block directive, i.e. {$ORIGIN xxxx} and {$ENDORIGIN}.
{$ORIGIN $2000}
procedure Init();
begin
end;

procedure doSomethin();
begin
end;

procedure Done();
begin
end;
{$ENDORIGIN}

In a block directive, defined functions would get consecutive addresses, counting from the indicated xxxx. A block directive, applied before the definition of UNIT would allow to specify where the library would be compiled. It might not even be necessary to enclose it - that would be sufficient.

{$ORIGIN $2000}
unit Somethin;

interface

implementation

end.

Recursion of {$ORIGN} directives - this is already a matter for discussion :) but I don't hide that it would be welcome :)

It would be possible to compile a part of the routines, e.g. under ROM, where it is also possible to run it - with restrictions, but still. Possibility to build dynamic libraries - of course, after adjusting the rest of the code accordingly.


You could also extend the above idea, not just to code: consider variables and the possibility to allocate them in any space in RAM by defining:

{$VARORIGIN $1000}
  var a:byte;
  b:String[40];
...
{$ENDVAR}

I know that a similar situation can be achieved by using the absolute modifier, but this would give a bit more "slack" in the code, and the possibility of assigning a default value, which can't be done now by using absolute.

@GSoftwareDevelopment GSoftwareDevelopment changed the title ORGIN directive [Feature] ORGIN directive Sep 13, 2023
@GSoftwareDevelopment
Copy link
Contributor Author

Extended memory banks when allocating using the {$ORIGN} directive.

For the moment, I would be willing to put the fact of taking care of the issue on the shoulders of the programmer/user:

  • loading into a bank
  • switching that bank
  • and restoring it.

It seems to me that everyone can have their own vision of how to do this - as long as they want to :) Maybe, in time, some interesting concept will be worked out, which can be permanently adopted in MAD Pascal :)


I point out that, I just wanted to raise this topic and I know that it will be (very) difficult to implement. It's an ambitious topic, with a lot of possibilities, but I think that for the time being, it can be somewhat "bypassed"
The fact that when possibly introducing such functionality - to make it easier - it's worth thinking at least a little bit about the suggested {$ORGIN} directive - because why re-write later, although.... it can be different :P ;)

@zbyti zbyti added the enhancement New feature or request label Feb 13, 2024
@zbyti zbyti changed the title [Feature] ORGIN directive [Feature Request] ORGIN directive Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants