News:

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

Code generation

Started by MusicalMike, July 29, 2005, 08:58:06 PM

Previous topic - Next topic

MusicalMike

Well I was still learning ASM with HLA (using the beta copy of art of assembly) I occasionally looked at the masm output that was created.

Rather than ask the question, Let me show you what concerns me.

The entirety of a simple hello world program written streight in masm

.486
.model flat, stdcall

include windows.inc
include masm32.inc
include kernel32.inc

includelib masm32.lib
includelib kernel32.lib

.const
myString db "Hello, World!", 0

.code
Start:
push offset myString
call StdOut
push 0
Call ExitProcess
End Start


Only the main entry point of the equivilant hla program masm output


_HLAMain        proc   near32


;/* Set up the Structured Exception Handler record */
;/* for this program. */

call   BuildExcepts__hla_
pushd   0                    ;/* No Dynamic Link. */
mov   ebp,  esp           ;/* Pointer to Main's locals */
push   ebp                  ;/* Main's display. */


push   offset32 L819_str__hla_
call   STDOUT_PUTS   ; puts
QuitMain__hla_::
pushd   00h
call   dword ptr [__imp__ExitProcess@4]
_HLAMain        endp

end


Basicly, my question is, why is the assembly output of hla programs so bloated, and wouldn't this cause the programs to run slower than in streight asm?

Sevag.K

The only "bloat" here is the inclusion of the structured exceptoin handler that HLA automatically generates for use with the standard library.
It's very small and has virtually nil impact on your program execution speed.

You can turn this feature off if you relly want.
see this document for a detailed answer to your question.

http://webster.cs.ucr.edu/AsmTools/HLA/HLADoc/HTMLDoc/DoingUnits.html

Randall Hyde

Quote from: MusicalMike on July 29, 2005, 08:58:06 PM

Basicly, my question is, why is the assembly output of hla programs so bloated, and wouldn't this cause the programs to run slower than in streight asm?

Output to the standard out (especially to a bitmapped screen) is about six orders of magnitude slower than any of the "bloat" in the standard HLA program. I wouldn't worry about it :-)

On a more serious side, HLA is optimized for beginners who are just learning assembly language and makes all kinds of concessions exactly for that audience. As you gain more experience, you can begin taking control back from HLA by doing things such as setting up @noframe, @nostackalign, @nodisplay, and even controlling object code generation.

Yes, you *can* write the same Hello World program in HLA that you can in MASM, but you'll have to learn how to do it. Sevag's already given you the main link, so I won't bother.

In the mean time, consider this -- programs that load into memory always consume code, data, and stack memory in 4K increments. So whenever you attempt to reduce the "bloat" in an HLA program, all you really wind up doing is letting more of those 4K blocks go unused. Either way, the program winds up using the same amount of physical memory, so you really haven't gained anything.

There is a time to be efficient, and a time when such attempts are a waste of time. For the Hello World program, it's a waste of time.
Cheers,
Randy Hyde