HL> Hello Tim
Howdy, Hans!
TH> For instance, I want to call an assembly SUB like any other
TH> SUB. eg.
TH> MySub MyString$
TH> I want to be able pass a literal or a simple string, or an array.
TH> I want the SUB to find out where the string is and set local
TH> pointers to it, like SI and DI. That way I can access and modify
TH> the string as needed.
HL> For accessing strings in assembler procedures PB has some internal
HL> procedures. The one you need here is GetStrLoc. It gives the length
HL> of the string in CX and a pointer in DX:AX. When you use PB's
HL> assembler it goes like this:...
I read about these in the users manual that came with 3.2, but it
seemed clear they applied to *external* subs, and I didn't bother to
work with them. Here, you are saying that I can call them as in-line
routines, and "ASM" type subs. That's good to know.
When i need to read strings, I have been accessing the location by
using STRPTR and STRSEG. It is a bit more indirect than what you had
shown, but I don't have to declare calls. However, I can not with
with the string, I can only read it, or modify it as long as the
length is unchanged. Of course, if I wanted to shorten a string, I
could do something like pad the end with spaces and use LTRIM$. But
that is about the extent of my usage.
HL> You can change the string from this sub. If you declare the string
HL> parameter as BYVAL you can access the string, but you can't change
HL> it. The string handle itself is pushed on the stack instead of its
HL> pointer. That's two bytes shorter, and you can access it faster. The
HL> necessary code is:
I suspect that the speed is the same, as the pointers have to be
gotten on the other end anyway.
HL> For function parameters it is not different. To return a value for a
HL> string function you have to allocate a new string and return the
HL> handle as function value. Example:
This seem to be a effient way to go.
HL> Try it yourself!
What a dangerous proposition...
--- Maximus/2 3.01
---------------
* Origin: Madman BBS * Chico, California * 916-893-8079 * (1:119/88)
|