News:

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

Definitions

Started by juliomacedo, January 13, 2006, 05:32:58 AM

Previous topic - Next topic

juliomacedo

Hi,

I hope someone may help me.

1. Were HLA instructions defined using HLA-CTL? If so, what's the header file with definitions of while, if, etc.?

2. I'd also like to know where are the definitions for put methods in stdout.hhf. It points to strange things as:

@external( "STDOUT_PUTB" );

What @external exactly means? What is STDOUT_PUTB? Where is its definition?

Thanks  :U

Julio


Sevag.K

Quote from: juliomacedo on January 13, 2006, 05:32:58 AM
Hi,

I hope someone may help me.

1. Were HLA instructions defined using HLA-CTL? If so, what's the header file with definitions of while, if, etc.?

The CTL is built into the compiler, there are no definition files for them.  See the HLA refernece manual or "Art of Assembly Language" for a full description.

Quote
2. I'd also like to know where are the definitions for put methods in stdout.hhf. It points to strange things as:

@external( "STDOUT_PUTB" );

What @external exactly means? What is STDOUT_PUTB? Where is its definition?

Thanks  :U

Julio



@external means the function is located in an external file (object file or library) which the linker uses to link in the code into your program.  The actual "put" routine, eg: stdout.put ( ... ); is a macro which translates all the arguments you pass to the 'put' macro into individual function calls eg: STDOUT_PUTB.

See the HLA Standard Library manual for more information.


juliomacedo

No, no, no... I'd like to know if HLA instructions (not HLA-CTL instructions) like while, if, try, etc. were defined with HLA-CTL macros or if they are built into compiler just as HLA-CTL...

I've just read AoA, Volume 04, Chapter 09, "Domain Specific Language" and I'm thinking if HLA instructions were defined using macros...



Evenbit

According to this page:  http://webster.cs.ucr.edu/AsmTools/HLA/index.html
"HLA is an open-source, public domain, system."

However, I don't see a link to the source.  You will probably have to search SourceForge for it.

Nathan.

Sevag.K

Quote from: juliomacedo on January 13, 2006, 01:46:48 PM
No, no, no... I'd like to know if HLA instructions (not HLA-CTL instructions) like while, if, try, etc. were defined with HLA-CTL macros or if they are built into compiler just as HLA-CTL...

I've just read AoA, Volume 04, Chapter 09, "Domain Specific Language" and I'm thinking if HLA instructions were defined using macros...


The HLA control instructions are built into the compiler.  Don't let this stop you from writing your own macros to simulate control structures though, there are some examples on Webster.

Here is a very primitive example of an "if-else-endif" control structure by user-defined macro.
Note that the expression evaluator is also built in, wirting a replacement for that would be much more involved.


//=========================================================================\\
// simple if..else..endif macro, does not support elseif

#macro _if(expr): jmpfalse,ifdone,withelse;
?withelse:=false;
jf(expr) jmpfalse;

#keyword _else;
#if(withelse)
#error("multiple _else statements");
#else
?withelse:=true;
jmp ifdone;
jmpfalse:
#endif

#terminator _endif;
#if(withelse)
ifdone:
#else
jmpfalse:
#endif
#endmacro



Randall Hyde

Quote from: juliomacedo on January 13, 2006, 01:46:48 PM
No, no, no... I'd like to know if HLA instructions (not HLA-CTL instructions) like while, if, try, etc. were defined with HLA-CTL macros or if they are built into compiler just as HLA-CTL...

I've just read AoA, Volume 04, Chapter 09, "Domain Specific Language" and I'm thinking if HLA instructions were defined using macros...




No, they were not. They could have been (assuming JT and JF were implemented) as CH9 describes, but the problem with doing so is that macro processing is quite slow.  It would probably double the compile time of a typical HLA program (or worse) if the control statements were implemented via macros.
Cheers,
Randy Hyde

juliomacedo

So, how can I know more about HLA implementations of theses HLL-like instructions so I can choose when to use HLA implementations and when to use my own implementations?

Sevag.K

The best way is to see what assembly code HLA generates for these instructions (look at the <filename>.asm file).

for example:

This HLA code

if (eax < 1000 && !ecx || ebx != 25 ) then
and (eax, eax);
endif;


generates:



cmp eax, 03e8h ;/* 1000 */
jnb L3__hla_
test ecx,ecx
je L2__hla_
L3__hla_:
cmp ebx, 019h ;/* 25 */
je L1_false__hla_
L2__hla_:
and eax, eax
L1_false__hla_:




Which is good enough for me to use the HLA statement rather than mix my own brew.


juliomacedo

Looking for the code in asm file seems a very good solution and the way HLA implemented your IF was really great!




MichaelW

Out of curiosity I implemented a similar .IF block in MASM:

.if (eax < 1000 && !ecx || ebx != 25 )
    and   eax, eax
.endif


This is the code that MASM generated:

00401000 3DE8030000             cmp     eax,3E8h
00401005 7304                   jnb     loc_0040100B
00401007 0BC9                   or      ecx,ecx
00401009 7405                   jz      loc_00401010
0040100B                    loc_0040100B:
0040100B 83FB19                 cmp     ebx,19h
0040100E 7402                   jz      loc_00401012
00401010                    loc_00401010:
00401010 23C0                   and     eax,eax
00401012                    loc_00401012:
eschew obfuscation

juliomacedo

JZ is a bit faster than JE isn't it?

MichaelW

QuoteJZ is a bit faster than JE isn't it?

For MASM, and HLA at least when using ML as the back end, and I think for most x86 assemblers, JZ and JE both assemble to the same opcode. The MASM 6 reference lists 12 of these conditional jump mnemonic "pairs", where both mnemonics in the pair specify the same opcode:

JB/JNAE
JAE/JNB
JBE/JNA
JA/JNBE
JE/JZ
JNE/JNZ
JL/JNGE
JGE/JNL
JLE/JNG
JG/JNLE
JP/JPE
JNP/JPO
eschew obfuscation

juliomacedo

And what about JE/JZ and other instructions?

Is there a difference in performance between a JE and a JAE for example?

MichaelW

QuoteIs there a difference in performance between a JE and a JAE for example?

At least up through the Pentium/Pentium MMX, Intel listed all of the conditional jump instructions as having the same basic timings. For the early processors there were different timings for jump and no jump, so for example on the 486 a conditional jump took 3 cycles if the jump was taken and 1 if it was not. Using ML 6.14 with the /Sc (Generate timings in listing) option, for the conditional jump instructions I get "3,1" with a .486 processor directive, and "1" with a .586 processor directive (and no timings with a .686 processor directive).


eschew obfuscation

juliomacedo

Quote from: MichaelW on January 20, 2006, 09:05:44 PM
Intel listed all of the conditional jump instructions as having the same basic timings...

Where is it???