News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

A few questions about HLA.-...

Started by indiocolifa, September 23, 2005, 06:12:02 PM

Previous topic - Next topic

indiocolifa

I've a few questions to ask about purposes of HLA commands/directives.

1) What is the purpose of HLA coroutines?
2) What is the purpose to define new segments in a 32-bit flat HLA program?
3) What is the purpose of @USE directive and how i can use it on my procedures?

thank you very much....!!!!

Sevag.K


1) What is the purpose of HLA coroutines?

Cross-platform multi-threading support.


2) What is the purpose to define new segments in a 32-bit flat HLA program?

Compatibility with some HLL compilers.  This feature may be depricated or changed, so use sparingly.


3) What is the purpose of @USE directive and how i can use it on my procedures?

Sometimes, HLA needs to use a register when preparing HLL style parameter passing procedures.  To do this, it preserves the reigster used (push/pop).  The @USE reg32 procedure option tells HLA that it can use the specified register without preserving it.

To use it, just declare it in the procedure options.  EAX is often a good choice as that is scrapped most of the time anyway.

procedure myProc ( var myvar:dword ); @USE eax;
...


Randall Hyde

Quote from: indiocolifa on September 23, 2005, 06:12:02 PM
I've a few questions to ask about purposes of HLA commands/directives.

1) What is the purpose of HLA coroutines?
Coroutines are a control structure, like procedures and functions, that allow an application to switch from one spot to another, much like a process switch in a multi-tasking OS. Coroutines are great for code that "takes turns" such as games. They are also very useful for creating "generators" (functions that maintain state across calls). See the following link for more details:

http://en.wikipedia.org/wiki/Coroutine


Quote
2) What is the purpose to define new segments in a 32-bit flat HLA program?
Largely, it is for compatibility with other object files that expect data in certain named sections. For all intents and purposes, named segments are equivalent to STATIC declarations.

Quote
3) What is the purpose of @USE directive and how i can use it on my procedures?

thank you very much....!!!!

From http://webster.cs.ucr.edu/AsmTools/HLA/HLADoc/HLARef/HLARef15.html#1026111


When passing parameters, HLA can sometimes generate better code if it has a 32-bit general purpose register for use as a scratchpad register. By default, HLA never modifies the value of a register behind your back; so it will often generate less than optimal code when passing certain parameters on the stack. By using the @use procedure option, you can specify one of the following 32-bit registers for use by HLA: eax, ebx, ecx, edx, esi, or edi. By providing one of these registers, HLA may be able to generate significantly better code when passing certain parameters.

Cheers,
Randy Hyde

indiocolifa

Can you give an example of the advantage of using @use?

Sevag.K

consider this small example


program tt;


procedure foo ( b:byte); @nodisplay; @noalignstack; //@use EAX;
begin foo;
end foo;

static
a :byte;
endstatic;

begin tt;
foo ( a );
end tt;


With @use EAX commented out, HLA generates this code everytime you call foo:


push eax
mov al, byte ptr [L2_a__hla_+0] ; a
mov byte ptr [ESP+4], al
pop eax
call L1_foo__hla_ ; foo


Uncomment @use EAX and HLA generates this code:


mov al, byte ptr [L2_a__hla_+0] ; a
push eax
call L1_foo__hla_ ; foo


more efficient, especially if you plan on making a lot of calls to foo.