Skip to content
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

[Optimizing] Extra jump to the correct part of the procedure when there are sub-functions in the function/procedure. #120

Open
GSoftwareDevelopment opened this issue Sep 14, 2023 · 3 comments

Comments

@GSoftwareDevelopment
Copy link
Contributor

We have such a piece of code:

Procedure myProc();

  Function myFunc:byte;
  Begin
    { some code here }
  End;

Begin
  { some code here }
End;

Begin
  myProc;
End.

Its result after compilation is more or less as follows:

{...}

.local MYPROC
  jmp l_xxx

.local MYFUNC
 { assembled code of function myFunc() }
  rts
.endl

l_xxx
 { assembled code of procedure myProc() }
 rts
.endl
{...}

{ somewhere in code }

  jmp MYPROC

{...}

Now, when the program makes a jump to the procedure myProc it jumps to the address where jmp l_xxx is, and not, to the address where the label l_xxx points to.
I can understand that this JMP l_xxx may be due to some compiler rules - forgive me, I don't know anything about compilers :) However, in time-critical situations, this jump is precious cycles.

My question.
Would it be possible to optimise this phenomenon? :)

I'll honestly say that even during debugging, it can mess with my head a bit ;) and I won't mention the precious cycles ;)

@tebe6502
Copy link
Owner

3 cycles ? really ?

@GSoftwareDevelopment
Copy link
Contributor Author

And you are asking for 3 cycles? Seriously? ;)

For my side, really really :D

@GSoftwareDevelopment
Copy link
Contributor Author

Don't be like a clerk sending you back to a room where they have to tell you where to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants