Skip to content

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

@GSoftwareDevelopment

Description

@GSoftwareDevelopment

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 ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions