Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. MASM 9.0 bug.

MASM 9.0 bug.

Scheduled Pinned Locked Moved The Lounge
help
22 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    Yes, add eax, 0 would reset the carry flag. Weird issue, but fortunately the fix is easy: don't align that loop. I know, it's common knowledge that loops should be aligned, and that used to help. But these days we have loop buffers and µop caches so it doesn't matter anymore, unless the loop is huge but then the effect is comparatively small.

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #12

    Well I'm glad you know what hell he's talking about because none of the rest of us do. I'm just gonna go crawl back into my JavaScript and PHP corner now...

    Jeremy Falcon

    1 Reply Last reply
    0
    • Z ZurdoDev

      What is MASM? You sure it isn't SPASM?

      There are only 10 types of people in the world, those who understand binary and those who don't.

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #13

      As far as it is not SPAM...

      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

      1 Reply Last reply
      0
      • M Member 4194593

        Where should I post a MASM 9.0 bug. It caused a very hard to find error (did not crash). Don't tell me MS, and don't ask why not. Dave.

        S Offline
        S Offline
        S Douglas
        wrote on last edited by
        #14

        Isn't the best place to post a Microsoft bug to, Microsoft? You know it will never be fixed thus never closed. Remain there forever :)


        Common sense is admitting there is cause and effect and that you can exert some control over what you understand.

        D 1 Reply Last reply
        0
        • P PhilLenoir

          Have you been at the Kool Aid again Griff?

          Life is like a s**t sandwich; the more bread you have, the less s**t you eat.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #15

          It's a PITA to chop and line up for snorting... :laugh:

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • S S Douglas

            Isn't the best place to post a Microsoft bug to, Microsoft? You know it will never be fixed thus never closed. Remain there forever :)


            Common sense is admitting there is cause and effect and that you can exert some control over what you understand.

            D Offline
            D Offline
            DJ van Wyk
            wrote on last edited by
            #16

            Just think of the warm-and-fuzzy feeling you will get for submitting it to Microsoft. I know they are still going to look at all those reports I submitted with Windows 95 and thank me later.

            My plan is to live forever ... so far so good

            M 1 Reply Last reply
            0
            • D DJ van Wyk

              Just think of the warm-and-fuzzy feeling you will get for submitting it to Microsoft. I know they are still going to look at all those reports I submitted with Windows 95 and thank me later.

              My plan is to live forever ... so far so good

              M Offline
              M Offline
              Member 4194593
              wrote on last edited by
              #17

              My feeling exactly, I was an ORCAS beta tester. Dave.

              1 Reply Last reply
              0
              • L Lost User

                Yes, add eax, 0 would reset the carry flag. Weird issue, but fortunately the fix is easy: don't align that loop. I know, it's common knowledge that loops should be aligned, and that used to help. But these days we have loop buffers and µop caches so it doesn't matter anymore, unless the loop is huge but then the effect is comparatively small.

                M Offline
                M Offline
                Member 4194593
                wrote on last edited by
                #18

                Harold,

                harold aptroot wrote:

                so it doesn't matter anymore

                I made some timing tests and it took 22% longer to execute an unaligned loop vs an aligned loop, and that was for a short count of loops needed to complete the job, and I had even longer counts I wanted to run. It does make a difference, align your loops! Dave.

                L 1 Reply Last reply
                0
                • M Member 4194593

                  Harold,

                  harold aptroot wrote:

                  so it doesn't matter anymore

                  I made some timing tests and it took 22% longer to execute an unaligned loop vs an aligned loop, and that was for a short count of loops needed to complete the job, and I had even longer counts I wanted to run. It does make a difference, align your loops! Dave.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #19

                  Ok, show your tests then, and I'll show you mine, which showed no difference. I've tested all 16 different alignments using these

                  global cmp0
                  proc_frame cmp0
                  [endprolog]
                  mov ecx, -10000000
                  xor eax, eax
                  jmp _cmp0_loop
                  align 16

                  _cmp0_loop:
                  add ecx, 1
                  jnz _cmp0_loop
                  ret
                  endproc_frame

                  ; etc

                  global cmp15
                  proc_frame cmp15
                  [endprolog]
                  mov ecx, -10000000
                  xor eax, eax
                  jmp _cmp15_loop
                  align 16
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  nop
                  _cmp15_loop:
                  add ecx, 1
                  jnz _cmp15_loop
                  ret
                  endproc_frame

                  Measured over 100 runs, taking the minimum, they all take 10000000 cyles + change (function call overhead and so on). No consistent or significant differences.

                  M 1 Reply Last reply
                  0
                  • L Lost User

                    Ok, show your tests then, and I'll show you mine, which showed no difference. I've tested all 16 different alignments using these

                    global cmp0
                    proc_frame cmp0
                    [endprolog]
                    mov ecx, -10000000
                    xor eax, eax
                    jmp _cmp0_loop
                    align 16

                    _cmp0_loop:
                    add ecx, 1
                    jnz _cmp0_loop
                    ret
                    endproc_frame

                    ; etc

                    global cmp15
                    proc_frame cmp15
                    [endprolog]
                    mov ecx, -10000000
                    xor eax, eax
                    jmp _cmp15_loop
                    align 16
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    nop
                    _cmp15_loop:
                    add ecx, 1
                    jnz _cmp15_loop
                    ret
                    endproc_frame

                    Measured over 100 runs, taking the minimum, they all take 10000000 cyles + change (function call overhead and so on). No consistent or significant differences.

                    M Offline
                    M Offline
                    Member 4194593
                    wrote on last edited by
                    #20

                    Harold, Your code is not doing the same thing, it is decrementing a register. My code was propagateing a borrow through multiple DWORDS. My timing indicated that the aligned code took 3.57 seconds to loop 100,000,000 (one hundred million) times, and 4.36 seconds to loop the same number of times for the unaligned test. That indicates that it took 1.22% longer. In addition, The loop had to re-initialize all of the DWORDS with the correct data for each loop. The loop included this initialization for both the base time and also for the test time, thus the time increment was due to only the time increment for the unaligned loop, meaning that the % difference is really in the neighborhood of 44%. I will give you the timing differences and the code changes between the two tests. If you want to see the the execution time differences (visual studio "disassembly" tab, then just ask and I will include that also.

                    RSA-Test TimeSbbLoop - 100M*TEST32: 3.57

                    ;
                    ; Code from Masm 9.0 .lst file for aligned test.
                    ;
                    C ;*******************************************************************************
                    C ;
                    C ; Timing test for alignment.
                    C ;
                    C ; esi has the source OFFSET of the data.
                    C ; edi has the already scaled OFFSET of the destination data.
                    C ; ecx has the DWORD count to subtract.
                    C ;
                    C ;*******************************************************************************
                    C ALIGN OWORD
                    00001AEE C .data
                    C
                    C ALIGN OWORD
                    00001AF0 00000020 [ C TestData DWORD 32 DUP (0) ; 128 BYTES, 8 xmm regs
                    00000000
                    ]
                    C
                    00001B70 00000001 C TestDWORD DWORD 1
                    C
                    C ALIGN WORD
                    00001B74 0023 C WORD (LENGTHOF szTestCase - 1)
                    00001B76 52 53 41 2D 54 C szTestCase BYTE "RSA-Test TimeSbbLoop - 100M*TEST32:",0
                    65 73 74 20 54
                    69 6D 65 53 62
                    62 4C 6F 6F 70
                    20 2D 20 31 30
                    30 4D 2A 54 45
                    53 54 33 32 3A
                    00
                    C
                    000006A0 C .code
                    C
                    C ;
                    C ; Get start time.
                    C ;
                    000006A0 C Start:
                    000006A0 E8 000054BB C CALL GetStartTime
                    C ; jnz Exit
                    C ;
                    C ; Clear the clear regs.
                    C ;
                    000006A5 66| 0F EF C0 C pxor xmm0,xmm0
                    000006A9 66| 0F 6F C8 C movdqa xmm1,xmm0
                    000006AD 66| 0F 6F D0 C

                    L 1 Reply Last reply
                    0
                    • M Member 4194593

                      Harold, Your code is not doing the same thing, it is decrementing a register. My code was propagateing a borrow through multiple DWORDS. My timing indicated that the aligned code took 3.57 seconds to loop 100,000,000 (one hundred million) times, and 4.36 seconds to loop the same number of times for the unaligned test. That indicates that it took 1.22% longer. In addition, The loop had to re-initialize all of the DWORDS with the correct data for each loop. The loop included this initialization for both the base time and also for the test time, thus the time increment was due to only the time increment for the unaligned loop, meaning that the % difference is really in the neighborhood of 44%. I will give you the timing differences and the code changes between the two tests. If you want to see the the execution time differences (visual studio "disassembly" tab, then just ask and I will include that also.

                      RSA-Test TimeSbbLoop - 100M*TEST32: 3.57

                      ;
                      ; Code from Masm 9.0 .lst file for aligned test.
                      ;
                      C ;*******************************************************************************
                      C ;
                      C ; Timing test for alignment.
                      C ;
                      C ; esi has the source OFFSET of the data.
                      C ; edi has the already scaled OFFSET of the destination data.
                      C ; ecx has the DWORD count to subtract.
                      C ;
                      C ;*******************************************************************************
                      C ALIGN OWORD
                      00001AEE C .data
                      C
                      C ALIGN OWORD
                      00001AF0 00000020 [ C TestData DWORD 32 DUP (0) ; 128 BYTES, 8 xmm regs
                      00000000
                      ]
                      C
                      00001B70 00000001 C TestDWORD DWORD 1
                      C
                      C ALIGN WORD
                      00001B74 0023 C WORD (LENGTHOF szTestCase - 1)
                      00001B76 52 53 41 2D 54 C szTestCase BYTE "RSA-Test TimeSbbLoop - 100M*TEST32:",0
                      65 73 74 20 54
                      69 6D 65 53 62
                      62 4C 6F 6F 70
                      20 2D 20 31 30
                      30 4D 2A 54 45
                      53 54 33 32 3A
                      00
                      C
                      000006A0 C .code
                      C
                      C ;
                      C ; Get start time.
                      C ;
                      000006A0 C Start:
                      000006A0 E8 000054BB C CALL GetStartTime
                      C ; jnz Exit
                      C ;
                      C ; Clear the clear regs.
                      C ;
                      000006A5 66| 0F EF C0 C pxor xmm0,xmm0
                      000006A9 66| 0F 6F C8 C movdqa xmm1,xmm0
                      000006AD 66| 0F 6F D0 C

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #21

                      Of course it's not doing the same thing, it's just testing the effect of alignment by itself. There is way too much shit here to be sure of anything.

                      M 1 Reply Last reply
                      0
                      • L Lost User

                        Of course it's not doing the same thing, it's just testing the effect of alignment by itself. There is way too much shit here to be sure of anything.

                        M Offline
                        M Offline
                        Member 4194593
                        wrote on last edited by
                        #22

                        Harold, My feelings exactly. I will use what I have and beware of any ALIGN in the code section except for the entry at PROC. I will insure that there is no entry to an aligned Label except by a jump or conditional jump. Dave.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups