News:

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

/Sc option in ML 6.15.8803

Started by Tight_Coder_Ex, December 04, 2010, 10:11:08 PM

Previous topic - Next topic

Tight_Coder_Ex

I'm have a problem finding details as to the result of /Sc

This is an excerpt of a listing where;
1) Address striped of leading zeros
2) Timings derived from opcodes.chm
3) No idea what these numbers mean
4) Opcodes
5) Mnemonics

Addr        Time   Opcode
------------------------------------------------------------------------
0E    1   517      33 C9        xor   ecx, ecx
10    1   262      8A C8        mov    cl,  al
12    3   517      C1 E8 08                     shr   eax, 8
15    3   645      91        xchg   eax, ecx
16    42   517      F7 E9        imul   ecx
18    1   517      50        push   eax
19    1   517      51        push   ecx


So at address OE, how 1 clock cycle equates to 517 is beyond me.

dedndave

so - where are the timings coming from ?
except for the dependancies, i would say about 15 clock cycles for the whole thing

i guess the times are 1,1,3,3,42,1,1
i have no idea what the 3rd column is - lol

to time it - you may have to make a slight change to balance the stack...
        xor     ecx,ecx
        mov     cl,al
        shr     eax,8
        xchg    eax,ecx
        imul    ecx
        push    eax
        pop     ecx

dedndave

well - i measure only ~11 clock cycles on my prescott (with no regard to the initial value in eax)...
10 10 10 10 10 11 12 11 11 10 10 10 11 10 10 10

Tight_Coder_Ex

When I create a listing using /Sc, the third column is the number generated by the assembler.

My system runs relatively 416 nano seconds/cycle, so maybe the 517 represented the number of pico seconds, BUT the assembler would have to know the speed of my CPU.
and as the SHR instruction takes 3 cycles, the number should have been 1551.  There is no logic to the output.

So the point is, how are these calculated and what do these numbers represent.  The most probably conclusion is MS didn't really care and this is a remnant from earlier versions.

I've tried to research MSDN, but all it tells me is that which I already know.

dedndave

only thing i can guess is - it is some kind of latency index or something
you have to use an abacus to tally clocks   :P
i especially like the complete absence of a coulmn title

MichaelW

Using this source:

;==============================================================================
    .386
    .model flat, stdcall
;==============================================================================
    .data
    .code
;==============================================================================
start:
;==============================================================================
    xor ecx, ecx
    mov cl, al
    shr eax, 8
    xchg eax, ecx
    imul ecx
    push eax
    push ecx
;==============================================================================
end start

If I assemble with /Fl /Sn /Sc, then the third column is absent in the listing, and the cycle counts (reasonably) conform to those listed in my v6.00 Microsoft Macro Assembler Reference (the wire-bound notebook-style reference).

Microsoft (R) Macro Assembler Version 6.15.8803     12/04/10 19:02:42
test.asm      Page 1 - 1


     ;==============================================================================
         .386
         .model flat, stdcall
     ;==============================================================================
00000000          .data
00000000          .code
     ;==============================================================================
00000000      start:
     ;==============================================================================
00000000   2   33 C9          xor ecx, ecx
00000002   2   8A C8          mov cl, al
00000004   3   C1 E8 08          shr eax, 8
00000007   3   91          xchg eax, ecx
00000008   9+  F7 E9          imul ecx
0000000A   2   50          push eax
0000000B   2   51          push ecx
     ;==============================================================================
     end start


And the same if I change to .486:

Microsoft (R) Macro Assembler Version 6.15.8803     12/04/10 19:06:03
test.asm      Page 1 - 1


     ;==============================================================================
         .486
         .model flat, stdcall
     ;==============================================================================
00000000          .data
00000000          .code
     ;==============================================================================
00000000      start:
     ;==============================================================================
00000000   1   33 C9          xor ecx, ecx
00000002   1   8A C8          mov cl, al
00000004   2   C1 E8 08          shr eax, 8
00000007   3   91          xchg eax, ecx
00000008  13+  F7 E9          imul ecx
0000000A   1   50          push eax
0000000B   1   51          push ecx
     ;==============================================================================
     end start
eschew obfuscation

Tight_Coder_Ex

Thanks Dave & Micheal and problem is solved.  I can use anything up to 586 or 586P, but as soon as I use 686 then the timming numbers don't make any sense at all.

MichaelW

For .586 I get:

Microsoft (R) Macro Assembler Version 6.15.8803     12/04/10 19:57:05
test.asm      Page 1 - 1


     ;==============================================================================
         .586
         .model flat, stdcall
     ;==============================================================================
00000000          .data
00000000          .code
     ;==============================================================================
00000000      start:
     ;==============================================================================
00000000   1   33 C9          xor ecx, ecx
00000002   1   8A C8          mov cl, al
00000004   1   C1 E8 08          shr eax, 8
00000007   2   91          xchg eax, ecx
00000008  11   F7 E9          imul ecx
0000000A   1   50          push eax
0000000B   1   51          push ecx
     ;==============================================================================
     end start


And for .686 there are no timings listed.
eschew obfuscation

Tight_Coder_Ex

To requalify, I get proper timings for all other than 686 or 686P, therefore my listings are the same as yours Micheal.  I can sleep better now that I know everything is right as rain in the Microsoft word!

God, I can't believe I just said that