Same Performance for Both Routines???

From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 03/27/04


Date: Sat, 27 Mar 2004 21:13:42 +0000 (UTC)


    I have written my C++ source code before it is converted into machine
language. Here is the machine code below that it is done by C/C++ Compiler.

    mov ecx,dword ptr [Low]
    mov edx,dword ptr [High]
    inc ecx
    mov eax,ecx
    and ecx,0FFh
    shr eax,8
    add edx,eax
    push eax
    and edx,0FFh
    mov [Carry],eax
    push edx
    push ecx
    push offset string "%X %X %X\n" (00408038)
    mov dword ptr [Low],ecx
    mov dword ptr [High],edx
    call _printf
    add esp,10h
    ret

    I don't like machine code above because it is not in the sequence order.
It can be difficult for me to understand, but I keep thinking the sequence
command. I have modified my machine code into sequence order. Here is
below.

    mov ecx,dword ptr [Low]
    inc ecx
    mov eax,ecx
    and ecx,0FFh
    mov dword ptr [Low],ecx
    shr eax,8
    mov edx,dword ptr [High]
    add edx,eax
    and edx,0FFh
    mov dword ptr [High],edx
    mov [Carry],eax
    push eax
    push edx
    push ecx
    push offset string "%X %X %X\n" (00408038)
    call _printf
    add esp,10h
    ret

    Do you think that first machine code is really optimized than second
machine code because I did my own optimization by hand. How can you be sure
that first machine code is much faster than second machine code however the
cycle count is the EXACT same? Please advise with your ideas.

-- 
Bryan Parkoff


Relevant Pages

  • Re: JMP Is Optimized?
    ... > Please look at my machine code below. ... > I believe that second machine code can be very optimized better than ... > first machine code by running much faster, but I am aware that second ...
    (comp.lang.asm.x86)
  • Re: How do I dig a memory value out?
    ... The only C compiler I could find at the time was ... The Atari keyboard was missing several characters, ... higher level language plus a few common data types ... hand tweeked machine code was entered directly in the ...
    (microsoft.public.vb.general.discussion)
  • Re: Basic compiler
    ... stand-alone executables in machine code were the "Einstein Compiler" ... and Microsoft's TASC (The AppleSoft Compiler). ...
    (comp.sys.apple2)
  • Re: Basic compiler
    ... stand-alone executables in machine code were the "Einstein Compiler" ... and Microsoft's TASC (The AppleSoft Compiler). ... Apple once made an effort to use the "R" file type in Apple ...
    (comp.sys.apple2)
  • Re: vm02 update
    ... Instant Pascal was a misguided attempt at creating an IDE with automatic formatting and almost instant feedback. ... Editing the source in a tokenized format would keep the memory constraints lower and ease the first pass of the compiler. ... compiled to machine code at all. ...
    (comp.sys.apple2.programmer)