From: | Tony Rolfe |
Date: | 11 Aug 99 at 04:40:22 |
Subject: | Re: Indirect Gosub |
On Mon, 9 Aug 1999 20:59:10 -0400 (EDT) said:
>
> Hi Tony,
>
>
> > Is there any way to store the address of a routine in a variable and
> > then gosub the routine based on the variable?
>
>
>
> There is no way that you can do that with a gosub anyway, as gosub takes a label.
> A label in a program represents an absolute memory location in the program code(It relative compared with RAM as exec relocates the code
> anyway, but it's an absolute offset in to the code).
> When a compiler sees a label it converts it to an address, and all subsequent calls to the label are filled in with the appropriate
> address.
>
>
> > I don't want to do an On... Gosub, because that means I have to change
> > the main routine each time I add a new calling routine.
>
> Why would on - gosub be inconvenient?
> If you considered using on - gosub, then I assume you need to test an expression before the routine is called.
> Either way I can't really see the benefit in loading a variable with a routine address, Why not just use functions or statements?
> Though if it's speed that your worried about then I can't really see anything faster than on - gosub, as loading a variable with an address
> after testing an expression would only result in more clock cycles.
>
> Well, maybe it's just me?
> Though I don't fully understand what your trying to accomplish.
Ok, what I really want to do.
I currently have a common routine which is gosubbed by over 50 outher
routines, passing a DIM LIST array and a report number to allow me to
keep track of which list I'm using at the time.
This is being converted to use david Newton's DLL routines. The
original had eight select statements of the form
Select report_number
case #CustomerList
NextItem Customers()
case #SupplierList
NextItem Suppliers()
etc.
Of course the NextItem is actually many different things, depending on
the context.
This has the consequence that, every time I add a new report, I have
to go in and update the eight select statements to add the new array.
Using DLL, I have eliminated all but two of the Selects. I Simply do
*TheList = *CustomerList or whatever
before calling the routine and the case statement simply becomes
NEXT_ITEM{*TheList}
The two I can't replace both use gosub somewhere different for each
array.
What I want to do is Header_Routine.l = Customer_headings (or whatever
the specific heading routine is called) before calling the routine.
Then I should be able to do something like
MOVE.L a0,Header_Routine
JSR 0(a0)
but me no speak 680x0 assembler.
There we are.
Cheers
---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie