Topic: Passing parameters with Call (1 of 10), Read 43 times
Conf: VEDIT User Applications
From: Daniel Bliss
Date: Monday, March 19, 2007 11:00 AM

Hello,

I'm trying to work out the best way to pass parameters to a called subroutine. Mostly I'm calling named subs within the same file, as in Call(":sub1"). Within 'sub1', I push the contents of user registers onto respective stacks, Num_Push(0,95) & Reg_Push(0,95); then re-initialize the numeric registers to 0. At the end of the sub, I pop the stack.
In this example I didn't push registers 96-99 to the stack so I can use their value from the parent routine as a work-around method of passing parameters to/from the called sub.
Can anyone suggest a better way of handling parameter passing? I've looked through the macro manual & this web-board, but didn't find any other ideas.
Thanks,
Dan

 


Topic: Re: Passing parameters with Call (2 of 10), Read 42 times
Conf: VEDIT User Applications
From: Ted Green
Date: Monday, March 19, 2007 12:28 PM

At 11:01 AM 3/19/2007, you wrote:
>From: "Daniel Bliss"
>I'm trying to work out the best way to pass parameters to a called subroutine. Mostly I'm calling named subs within the same file, as in Call(":sub1"). Within 'sub1', I push the contents of user registers onto respective stacks, Num_Push(0,95) & Reg_Push(0,95); then re-initialize the numeric registers to 0. At the end of the sub, I pop the stack.
>In this example I didn't push registers 96-99 to the stack so I can use their value from the parent routine as a work-around method of passing parameters to/from the called sub.
>Can anyone suggest a better way of handling parameter passing? I've looked through the macro manual & this web-board, but didn't find any other ideas.

Dan:

No, there is no better way to handling parameter passing in VEDIT. Sorry.

Ted.

 


Topic: Re: Passing parameters with Call (3 of 10), Read 37 times
Conf: VEDIT User Applications
From: Christian Ziemski
Date: Monday, March 19, 2007 05:51 PM

On Mon, 19 Mar 2007 11:00:00 -0400, Daniel Bliss wrote:

>I'm trying to work out the best way to pass parameters to a called subroutine.
>Mostly I'm calling named subs within the same file, as in Call(":sub1").
>Within 'sub1', I push the contents of user registers onto respective stacks,
>Num_Push(0,95) & Reg_Push(0,95); then re-initialize the numeric registers to 0.
>At the end of the sub, I pop the stack.
>In this example I didn't push registers 96-99 to the stack so I can use their
>value from the parent routine as a work-around method of passing parameters
>to/from the called sub.

Dan:

At least you can use the SET option when pushing text registers onto
the stack:

Reg_Push(r,s,SET) The specified registers are not emptied.


Christian

 


Topic: Passing parameters with Call (4 of 10), Read 42 times
Conf: VEDIT User Applications
From: Ian Binnie
Date: Monday, March 19, 2007 10:57 PM

On 3/19/2007 11:00:43 AM, Daniel Bliss wrote:
>Hello,

I'm trying to work out
>the best way to pass
>parameters to a called
>subroutine. Mostly I'm
>calling named subs within the
>same file, as in
>Call(":sub1"). Within 'sub1',
>I push the contents of user
>registers onto respective
>stacks, Num_Push(0,95) &
>Reg_Push(0,95); then
>re-initialize the numeric
>registers to 0. At the end of
>the sub, I pop the stack.

As Ted & Christian have stated, this is the only option.

You might want to consider why you are pushing/popping registers.

While this is how traditional languages handle registers, it is better to think of these as global variables.

If you plan the program, it is usually possible to allocate a range of registers to the main program & each procedure.

In most cases there are more than enough registers.
I only push/pop when I am writing procedures which involve recursive calls.

 


Topic: Re: Passing parameters with Call (5 of 10), Read 41 times
Conf: VEDIT User Applications
From: Ted Green
Date: Tuesday, March 20, 2007 10:54 AM


>From: Ian Binnie
>...
>In most cases there are more than enough registers.
>I only push/pop when I am writing procedures which involve recursive calls.

Or when writing a general purpose library of procedures.

Ted.

 


Topic: Passing parameters with Call (6 of 10), Read 41 times
Conf: VEDIT User Applications
From: Daniel Bliss
Date: Tuesday, March 20, 2007 11:08 AM

Gentlemen, thanks for feedback.

Ian:
My problem is somewhat recursive (yea...I keep mulling it over and over in my mind!) - in that I can't predict when and how often a sub (with local 'variables') will be called.
Dan Bliss

 


Topic: Passing parameters with Call (7 of 10), Read 39 times
Conf: VEDIT User Applications
From: Pauli Lindgren
Date: Wednesday, March 21, 2007 01:22 PM

On 3/20/2007 11:08:14 AM, Daniel Bliss wrote:
>My problem is somewhat recursive (yea...I keep mulling it
>over and over in my mind!) - in that I can't
>predict when and how often a sub (with local 'variables')
>will be called.

Remember that the stack size is limited (was it 256 registers?). So if you push all the registers in each call, you soon run out of stack space.

It is better to push only those registers you are actually using in the subroutine.

--
Pauli

 


Topic: Passing parameters with Call (8 of 10), Read 40 times
Conf: VEDIT User Applications
From: Daniel Bliss
Date: Wednesday, March 21, 2007 06:47 PM

At first I thought it would be safer to throw all 0-95 registers onto the stack, but that seemed overkill (and in the back of my mind I wondered about a limit of size of the stack). So I went with a parsimoniously fewest - only the registers re-used by the subroutine.

Thanks for the tip.

Despite not really supporting call args/parms Vedit's call function has restored needed order to my program. The trace during debugging bounces around more, but the register values are easier to track.

Thanks again, Dan

 


Topic: RE: Passing parameters with Call (9 of 10), Read 49 times
Conf: VEDIT User Applications
From: Lowell Dennis
Date: Thursday, March 22, 2007 11:41 AM

I think I may have another possible way to pass parameters to a macro
...

A long time ago I created a set of set of macros that would use one of
the extra text buffers as a stack. You could use this stack with amount
of arbitrary information of constant or even varying lengths. I just
checked and the macros are still on Christian's website
(http://www.ziemski.net/vedit/macros/misc.html). The file of interest
is STACK.VDM. This file provides INIT_STACK, PUSH, and POP functions.
INIT_STACK is passed in a buffer number and it sets that buffer up to be
a stack.
PUSH is passed the stack buffer number and a text register number.
Whatever is in the indicated text register is saved on the stack. POP
is passed the stack buffer number and a text register number. Whatever
was the last item pushed on to the stack is removed from the stack and
placed in the indicated text register.

Using these macros should easily reduce the amount of text registers you
will need to keep track of.

I used these macros in a fairly sophisticated tag/lookup system for the
massive amounts of BIOS code I was having to update. FILESTK.VDM
implements a stack that saves file names and file positions which would
allow me to move back and forth through the calling order of the BIOS
code.

You could setup a stack, push all of you arguments onto the stack and
then only have to pass the stack buffer number to your macro. The macro
could consume the items on the stack however it needs to.

I hope this helps and is not too late.

- Lowell

-----Original Message-----
From: vedit-userapps Listmanager
[mailto:vedit-userapps.listmanager@...]
Sent: Wednesday, March 21, 2007 5:48 PM
Subject: Passing parameters with Call

From: "Daniel Bliss"

At first I thought it would be safer to throw all 0-95 registers onto
the stack, but that seemed overkill (and in the back of my mind I
wondered about a limit of size of the stack). So I went with a
parsimoniously fewest - only the registers re-used by the subroutine.

Thanks for the tip.

Despite not really supporting call args/parms Vedit's call function has
restored needed order to my program. The trace during debugging bounces
around more, but the register values are easier to track.

Thanks again, Dan





To reply: mailto:vedit-userapps.31615@...
To start a new topic: mailto:vedit-userapps@...
To login: http://...
To (un)subscribe: mailto: vedit-userapps.list-request@...

 


Topic: RE: Passing parameters with Call (10 of 10), Read 58 times
Conf: VEDIT User Applications
From: Pauli Lindgren
Date: Friday, March 23, 2007 12:04 PM

On 3/22/2007 11:41:41 AM, Lowell Dennis wrote:
>
>I used these macros in a fairly sophisticated
>tag/lookup system for the massive amounts of BIOS code I
>was having to update.
>FILESTK.VDM implements a stack that saves
>file names and file positions which would
>allow me to move back and forth through the calling
>order of the BIOS code.

Looks similar to the method I use in my utags.vdm implementation I uploaded today :-)

--
Pauli