Re: Learning Assembly with an HLL



On Mon, 18 Jun 2007 11:41:51 -0600, "James Van Buskirk"
<spamtrap@xxxxxxxxxx> wrote:

"Bob Masta" <NoSpam@xxxxxxxxxxx> wrote in message
news:467688e5.9302378@xxxxxxxxxxxxxxxxxxxxx

Actually, I agree with you on this in general. I almost never
use macros of any other sort; but INVOKE actually helps
isolate the beautiful simplicity of assembly from the
unavoidable API stuff. I'd strongly recommend it to a student
to remove the API clutter and concentrate on his own
assembly code. This also reduces the chance of confusing
the string of PUSHes needed by the API from those you want
in your own code (such as saving registers that you know the
API will trash).

I typically think of you as a sensible guy, Bob, which is makes
it more difficult to comprehend why you would recommend INVOKE.
Consider that (in Windows x64) immediately before the CALL
instruction, the stack must be aligned to a multiple of 16
bytes and that the 32 bytes at top of stack must be available
to the callee as a parameter save area. If the assembler is
not sure about stack alignment before the INVOKE macro, it
must generate code to align the stack at every invocation.
In that case it would also have to create the 32 byte area
unilaterally.

If the assembler doesn't know where the scratch space in the
stack frame is, it would have to PUSH caller-save registers
and any arguments past the fourth, rather than use simpler
MOV instructions.

If the assembler does know all of the above stuff, that means
it has to have complete control over the stack frame at all
times, which makes any procedure look more like it written in
HLL rather than ASM. When you you INVOKE, you have to know
which of the alternatives is in force so that you have to
keep track of HLL abstractions rather than concentrate on the
object of the exercise which should have been to write good
clean low-level code from the start.


First of all, I have never done any x64 coding, and x32 doesn't
seem to need any special handling.

However, even considering the x64 situation you mention, I fail to see
any problem with INVOKE. In x32 at least, INVOKE does nothing
more than push the specified data in the required order for the call.
I surely hope that the same is true in x64, and that any special
pre-manipulation of the stack is entirely up to you... the assembler
doesn't have complete control of anything. This makes the argument
for INVOKE even stronger, IMHO, since it isolates the purely
"mechanical" pushes from any special handling that may be
required. By putting the API stuff all on one line of code, you
can clearly distinguish API code from everything else, including
special set-up code, if needed.

Best regards,


Bob Masta

D A Q A R T A
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Signal Generator
Science with your sound card!

.



Relevant Pages

  • Re: Learning Assembly with an HLL
    ... unavoidable API stuff. ... it more difficult to comprehend why you would recommend INVOKE. ... bytes and that the 32 bytes at top of stack must be available ... If the assembler doesn't know where the scratch space in the ...
    (comp.lang.asm.x86)
  • Re: Is MASM32 an evil Microsoft plot? (Part 2)
    ... push offset titletxt ... invoke MessageBox,hWnd,ADDR TxtMsg,ADDRTtlTxt,MB_OK ... MASM code through the most powerful assembler available in 32 bit ... and API call is just that, ...
    (alt.lang.asm)
  • Re: Quick question about streams...?
    ... For loops and structures are the C language. ... The API is a bunch of functions. ... I don't know what "runs on assembler" means. ... A C compiler usually starts ...
    (microsoft.public.vc.language)
  • Re: Quick question about streams...?
    ... For loops and structures are the C language. ... The API is a bunch of functions. ... I don't know what "runs on assembler" means. ... A C compiler usually starts ...
    (microsoft.public.vc.language)
  • Re: Slider Bar in eVB?
    ... > answer "your solution is in CreateWindowEx API Call, ... questioners level of programming skills to be. ... do xxx and yyy, but cant find the API way to accomplish zzz", then the asker ... > Assembler" just can be a final word of a argue. ...
    (microsoft.public.windowsce.embedded.vb)