> In a pure assembly program, without any C component,
> I'm curious why even have a main function like that.
> It would seem that much simpler to just go straight into the main code,
> and call ExitProcess directly.
True, but for a C coder, it seems to make more sense to have main function. If I wanted to add a slight boost in speed (the main function is only meant to be called once...ever), I could merge the _start procedure and the main function, just as you can add things like constant strings in the TEXT section when it is meant to be in the RDATA (read-only data) section.
>> (msg_end - msg) / 2
> I assume you copied that from the other site... I'd
> been using that sort of thing, but, if I remember
> right, I came up with it on my own. (that was a
> few months ago, so my memory may be wrong.) I
> guess a lot of good ideas will be thought of by
> multiple people. Or had you just adapted it from
> my code? (not that there would be anything
> wrong with that, certainly.)
Well, the `msg_end - msg' was a "trick" I learned (and forgot) long ago that you made me remember because of your code. As for the division by 2, that's easy to figure out since Unicode is 16 bits (2 bytes) in Windows, and WriteConsole uses the number of characters (not necessarily the number of bytes); `msg_end - msg' results in a difference in bytes, so dividing by 2 makes sense, not to mention the fact that I was getting annoyed at the squares (CHR$(219)?) and other random characters that were printing to the screen because I had forgotten that the calculation for the number of characters changes when you change to Unicode. :P
>> enter 20, 0
>> mov DWORD [esp + 16], 0
>> sub esp, 20
> reserving stack space, and then using mov instead
> of push... That's an interesting way of doing it.
> I'm curious why do it that way? Is there a
> performance advantage, or is it just programmer
> preference? In my opinion, it is less straight
The PUSH instruction can be used to save space in the resulting executable. However, small code doesn't always mean fast code. PUSH 0 and MOV DWORD [esp + N], 0 should take the same amount of time in theory. See PUSH and MOV for more information. It's one of my favourite references when I need to look up an x86 assembly language instruction.
As for the DLL vs importlib idea, I haven't a clue.
And yes, I was that Anonymous. :P
|Response Title||Author and Date|
|*cool.||on May 8, 8:15 PM|