Given that after its first invocation, a beeb's procedure is faster than line number based Gosubs, due to the cached address of the Proc defintion, I wondered if any Bbc basic descendant gained a Dummy parse command to fill the procedure etc address cache table?..
Eg something like a PARSETOCACHE * command called once at start of programme for when a slight initial delay (eg while game instructions are shown) is a good trade off against a faster first call of each routine?
*others can probably think of better names..
Dummy parse command to fill procedure table?
Re: Dummy parse command to fill procedure table?
PROCthing(-1)
....
DEFPROCthing(A%):IF A%<0 THEN ENDPROC
...
do stuff
...
ENDPROC
....
DEFPROCthing(A%):IF A%<0 THEN ENDPROC
...
do stuff
...
ENDPROC
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
Re: Dummy parse command to fill procedure table?
But now the 1st line of the procedure is slowing it down every time its called , in addition to the speed cost of an extra parameter/memory cost if made a global flag .... I suppose you could have self modifying code that deleted the 1st line of every procedure and said global after first call of every procedure (from an entire procedure called buildprocedurecache which is then also deleted) ?
Re: Dummy parse command to fill procedure table?
You're over-thinking this!
The slow-down is only ever applicable the first time a PROCedure or FN is called; and it's not that much, in any case. You could speed up the search by putting all your DEFPROCs at the beginning of your program, with a GOTO to jump past them.
But the prevailing attitude at the time was "if you really need as much speed as possible, why are you still using BASIC?"
The slow-down is only ever applicable the first time a PROCedure or FN is called; and it's not that much, in any case. You could speed up the search by putting all your DEFPROCs at the beginning of your program, with a GOTO to jump past them.
But the prevailing attitude at the time was "if you really need as much speed as possible, why are you still using BASIC?"
Re: Dummy parse command to fill procedure table?
Consider PROCinit(-1)
Miserable old curmudgeon who still likes a bit of an ARM wrestle now and then. Pi 4, 3, ARMX6, SA Risc PC, A540, A440
Re: Dummy parse command to fill procedure table?
Routine definitions first would be Pascal like which would seem appropriate for bbcbasic, but a goto would not be... so it would be nice if the goto* could be left out and the parser simply updated its procedure-address table as it read past the definitions, looking for a non definition to parse?.... but multiple endprocs presumably would need a new keyword to mean program code starts , so from Pascal PROGRAMBEGIN / BEGIN...?
EDIT just noticed next post with a neat trick to avoid need for...BEGIN using a PROCmain (C inspired?)...perhaps PROCprogram_begin would be more Pascally...
The bbc manual seemed rather offputting about machine code (unlike the atom manual it seems), so I never learnt it univ.
Last edited by B3_B3_B3 on Tue Apr 30, 2024 7:44 pm, edited 2 times in total.
Re: Dummy parse command to fill procedure table?
Dunno if this would work at speeding up, but it avoids the GOTO.
Code: Select all
10 PROCmain
20 END
100.... all the normal procedures the program needs
20000 DEF PROCmain
....main code goes here
29900 ENDPROC
Rgds
Stephen
Stephen