OpenAmiga (165/964)

From:Guillermo Rodriguez Garcia
Date:7 Sep 2000 at 12:02:09
Subject:Re: AMIOPEN: tcall macro

At 10:46 AM 9/1/00 -0700, you wrote:
>Just posted a VP assembly macro to the Faq-O-Matic that allows
>you to make arbitrary tool calls. That is, lets you decide what tool
>to call at run-time. Example:
>
> tcall toolname.p, (p0 p1 p2 i0 : i0), was_tool_found

Very nice, but if someone uses this macro within code that does
not use register symbolic names by itself, you will mess up their
registers.

For example:

tool 'test', VP, F_MAIN, 8192, 0
ent -:-

cpy.p $12345678, p0
tcall toolname.p
tracef "%p\n", p0

ret
toolend

To partially avoid this, change the 'defbegin' to a 'defbegin 1'
which makes sure that this is _not_ the outermost defbegin...defend
block. This way it will only work if the calling code is using
defbegin...defend itself, which is bad, but not as bad as it
currently is.

The proper solution would be smthing like allocating space in the
stack for tcall_head, tcall_node, instead of using registers. I
haven't tried this, though.

Regards,
G.

Subscribe/Unsubscribe: open-request@amiga.com
Amiga FAQ: http://www.amiga.com/faq.html