Click here to Skip to main content
15,892,059 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: MASM 9.0 bug. Pin
Richard MacCutchan15-Jan-15 9:00
mveRichard MacCutchan15-Jan-15 9:00 
GeneralRe: MASM 9.0 bug. Pin
newton.saber15-Jan-15 9:14
newton.saber15-Jan-15 9:14 
GeneralRe: MASM 9.0 bug. Pin
Member 419459315-Jan-15 9:27
Member 419459315-Jan-15 9:27 
GeneralRe: MASM 9.0 bug. Pin
harold aptroot15-Jan-15 9:36
harold aptroot15-Jan-15 9:36 
GeneralRe: MASM 9.0 bug. Pin
Jeremy Falcon15-Jan-15 12:15
professionalJeremy Falcon15-Jan-15 12:15 
GeneralRe: MASM 9.0 bug. Pin
Member 419459316-Jan-15 4:32
Member 419459316-Jan-15 4:32 
GeneralRe: MASM 9.0 bug. Pin
harold aptroot16-Jan-15 5:01
harold aptroot16-Jan-15 5:01 
GeneralRe: MASM 9.0 bug. Pin
Member 419459316-Jan-15 6:33
Member 419459316-Jan-15 6:33 
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     movdqa xmm2,xmm0
 000006B1  66| 0F 6F D8	      C     movdqa xmm3,xmm0
 000006B5  66| 0F 6F E0	      C     movdqa xmm4,xmm0
 000006B9  66| 0F 6F E8	      C     movdqa xmm5,xmm0
 000006BD  66| 0F 6F F0	      C     movdqa xmm6,xmm0
 000006C1  66| 0F 6F F8	      C     movdqa xmm7,xmm0
			      C ;
			      C ;   Set the loop counter.
			      C ;
			      C ;    mov    edx,1
 000006C5  BA 05F5E100	      C     mov    edx,100000000
			      C 
 000006CA		      C OneTest:
 000006CA  BE 00001AF0 R      C     mov    esi,OFFSET TestData
 000006CF  33 C0	      C     xor    eax,eax
 000006D1  B9 00000001	      C     mov    ecx,1
 000006D6  8B FE	      C     mov    edi,esi
 000006D8  66| 0F 7F 06	      C     movdqa [esi + 0],xmm0
 000006DC  66| 0F 7F 4E	      C     movdqa [esi + 16],xmm1
	   10
 000006E1  66| 0F 7F 56	      C     movdqa [esi + 32],xmm2
	   20
 000006E6  66| 0F 7F 5E	      C     movdqa [esi + 48],xmm3
	   30
 000006EB  66| 0F 7F 66	      C     movdqa [esi + 64],xmm4
	   40
 000006F0  66| 0F 7F 6E	      C     movdqa [esi + 80],xmm5
	   50
 000006F5  66| 0F 7F 76	      C     movdqa [esi + 96],xmm6
	   60
 000006FA  66| 0F 7F 7E	      C     movdqa [esi + 112],xmm7
	   70
 000006FF  BB FFFFFFFF	      C     mov    ebx,-1
 00000704  89 5E 7F	      C     mov    DWORD PTR [esi + 127],ebx
 00000707  BE 00001B70 R      C     mov    esi,OFFSET TestDWORD
 0000070C  EB 02	      C     jmp    DoAll
			      C 
			      C ALIGN      OWORD
			      C 
			      C ;
			      C ;   Subtract all the value DWORDS.
			      C ;
 00000710		      C DoAll:
 00000710  8B 1E	      C     mov    ebx,[esi]
 00000712  8D 76 04	      C     lea    esi,[esi + (SIZEOF DWORD)]
 00000715  19 1F	      C     sbb    [edi],ebx
 00000717  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 0000071A  49		      C     dec    ecx
 0000071B  75 F3	      C     jnz    DoAll
 0000071D  72 11	      C     jc     Again
 0000071F  EB 16	      C     jmp    Done
			      C ;
			      C ;   This is the copy of the code that failed.
			      C ;   The first run will be a baseline where the code is naturally aligned,
			      C ;   then padding instructions will be added to force mis-alignment,
			      C ;   then the test will be run again.
			      C ;
			      C ;   Pad the code to align "Again" naturally on a mod 16 (OWORD) boundary.
			      C ;   This code is not ever executed - just the above code less the dec ecx.
			      C ;
 00000721  8B 1E	      C     mov    ebx,[esi]
 00000723  8D 76 04	      C     lea    esi,[esi + (SIZEOF DWORD)]
 00000726  19 1F	      C     sbb    [edi],ebx
 00000728  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 0000072B  49		      C     dec    ecx
 0000072C  75 E2	      C     jnz    DoAll
 0000072E  72 00	      C     jc     Again
			      C 
			      C ;ALIGN      OWORD
			      C 
			      C ;
			      C ;  Un-pad the code to un-align.
			      C ;
			      C ;
			      C ;   Propogate the borrow.
			      C ;
 00000730		      C Again:
 00000730  19 07	      C     sbb    [edi],eax
 00000732  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 00000735  72 F9	      C     jc     Again
			      C ;
			      C ;   Done with one test.
			      C ;
 00000737		      C Done:
 00000737  4A		      C     dec    edx
 00000738  75 90	      C     jnz    OneTest
			      C ;
			      C ;   Get the stop time.
			      C ;
 0000073A  E8 00005451	      C     CALL   GetStopTime
			      C ;    jnz    Exit
			      C ;
			      C ;   Print the test time.
			      C ;
			      C     INVOKE WriteNStr,OFFSET szCRLF
 0000073F  68 00001956 R   *	    push   dword  ptr OFFSET FLAT: szCRLF
 00000744  E8 00004947	   *	    call   WriteNStr
 00000749  75 1D	      C     jnz    Exit
			      C 
			      C     INVOKE WriteNStr,OFFSET szTestCase
 0000074B  68 00001B76 R   *	    push   dword  ptr OFFSET FLAT: szTestCase
 00000750  E8 0000493B	   *	    call   WriteNStr
 00000755  75 11	      C     jnz    Exit
			      C 
 00000757  E8 000052F4	      C     CALL   FormatElapsed
			      C ;    jnz    Exit
			      C 
			      C     INVOKE WriteNStrCRLF,OFFSET szTOD
 0000075C  68 00001AE2 R   *	    push   dword  ptr OFFSET FLAT: szTOD
 00000761  E8 0000495A	   *	    call   WriteNStrCRLF
 00000766  75 00	      C     jnz    Exit


RSA-Test TimeSbbLoop - 100M*TEST32:       4.36

;
;   Code from MASM 9.0 .lst file for unaligned 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     movdqa xmm2,xmm0
 000006B1  66| 0F 6F D8	      C     movdqa xmm3,xmm0
 000006B5  66| 0F 6F E0	      C     movdqa xmm4,xmm0
 000006B9  66| 0F 6F E8	      C     movdqa xmm5,xmm0
 000006BD  66| 0F 6F F0	      C     movdqa xmm6,xmm0
 000006C1  66| 0F 6F F8	      C     movdqa xmm7,xmm0
			      C ;
			      C ;   Set the loop counter.
			      C ;
			      C ;    mov    edx,1
 000006C5  BA 05F5E100	      C     mov    edx,100000000
			      C 
 000006CA		      C OneTest:
 000006CA  BE 00001AF0 R      C     mov    esi,OFFSET TestData
 000006CF  33 C0	      C     xor    eax,eax
 000006D1  B9 00000001	      C     mov    ecx,1
 000006D6  8B FE	      C     mov    edi,esi
 000006D8  66| 0F 7F 06	      C     movdqa [esi + 0],xmm0
 000006DC  66| 0F 7F 4E	      C     movdqa [esi + 16],xmm1
	   10
 000006E1  66| 0F 7F 56	      C     movdqa [esi + 32],xmm2
	   20
 000006E6  66| 0F 7F 5E	      C     movdqa [esi + 48],xmm3
	   30
 000006EB  66| 0F 7F 66	      C     movdqa [esi + 64],xmm4
	   40
 000006F0  66| 0F 7F 6E	      C     movdqa [esi + 80],xmm5
	   50
 000006F5  66| 0F 7F 76	      C     movdqa [esi + 96],xmm6
	   60
 000006FA  66| 0F 7F 7E	      C     movdqa [esi + 112],xmm7
	   70
 000006FF  BB FFFFFFFF	      C     mov    ebx,-1
 00000704  89 5E 7F	      C     mov    DWORD PTR [esi + 127],ebx
 00000707  BE 00001B70 R      C     mov    esi,OFFSET TestDWORD
 0000070C  EB 02	      C     jmp    DoAll
			      C 
			      C ALIGN      OWORD
			      C 
			      C ;
			      C ;   Subtract all the value DWORDS.
			      C ;
 00000710		      C DoAll:
 00000710  8B 1E	      C     mov    ebx,[esi]
 00000712  8D 76 04	      C     lea    esi,[esi + (SIZEOF DWORD)]
 00000715  19 1F	      C     sbb    [edi],ebx
 00000717  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 0000071A  49		      C     dec    ecx
 0000071B  75 F3	      C     jnz    DoAll
 0000071D  72 0F	      C     jc     Again
 0000071F  EB 14	      C     jmp    Done
			      C ;
			      C ;   This is the copy of the code that failed.
			      C ;   The first run will be a baseline where the code is naturally aligned,
			      C ;   then padding instructions will be added to force mis-alignment,
			      C ;   then the test will be run again.
			      C ;
			      C ;   Pad the code to align "Again" naturally on a mod 16 (OWORD) boundary.
			      C ;   This code is not ever executed - just the above code less the dec ecx.
			      C ;
 00000721  8B 1E	      C     mov    ebx,[esi]
 00000723  8D 76 04	      C     lea    esi,[esi + (SIZEOF DWORD)]
 00000726  19 1F	      C     sbb    [edi],ebx
 00000728  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 0000072B  49		      C     dec    ecx
 0000072C  75 E2	      C     jnz    DoAll
			      C ;   jc     Again ********************** Remove this pad instruction to un-align.
			      C 
			      C ;ALIGN      OWORD
			      C 
			      C ;
			      C ;  Un-pad the code to un-align.
			      C ;
			      C ;
			      C ;   Propogate the borrow.
			      C ;
 0000072E		      C Again:
 0000072E  19 07	      C     sbb    [edi],eax
 00000730  8D 7F 04	      C     lea    edi,[edi + (SIZEOF DWORD)]
 00000733  72 F9	      C     jc     Again
			      C ;
			      C ;   Done with one test.
			      C ;
 00000735		      C Done:
 00000735  4A		      C     dec    edx
 00000736  75 92	      C     jnz    OneTest
			      C ;
			      C ;   Get the stop time.
			      C ;
 00000738  E8 00005453	      C     CALL   GetStopTime
			      C ;    jnz    Exit
			      C ;
			      C ;   Print the test time.
			      C ;
			      C     INVOKE WriteNStr,OFFSET szCRLF
 0000073D  68 00001956 R   *	    push   dword  ptr OFFSET FLAT: szCRLF
 00000742  E8 00004949	   *	    call   WriteNStr
 00000747  75 1D	      C     jnz    Exit
			      C 
			      C     INVOKE WriteNStr,OFFSET szTestCase
 00000749  68 00001B76 R   *	    push   dword  ptr OFFSET FLAT: szTestCase
 0000074E  E8 0000493D	   *	    call   WriteNStr
 00000753  75 11	      C     jnz    Exit
			      C 
 00000755  E8 000052F6	      C     CALL   FormatElapsed
			      C ;    jnz    Exit
			      C 
			      C     INVOKE WriteNStrCRLF,OFFSET szTOD
 0000075A  68 00001AE2 R   *	    push   dword  ptr OFFSET FLAT: szTOD
 0000075F  E8 0000495C	   *	    call   WriteNStrCRLF
 00000764  75 00	      C     jnz    Exit


Dave.
GeneralRe: MASM 9.0 bug. Pin
harold aptroot16-Jan-15 7:21
harold aptroot16-Jan-15 7:21 
GeneralRe: MASM 9.0 bug. Pin
Member 419459316-Jan-15 12:17
Member 419459316-Jan-15 12:17 
GeneralRe: MASM 9.0 bug. Pin
S Douglas15-Jan-15 18:55
professionalS Douglas15-Jan-15 18:55 
GeneralRe: MASM 9.0 bug. Pin
DJ van Wyk16-Jan-15 0:32
professionalDJ van Wyk16-Jan-15 0:32 
GeneralRe: MASM 9.0 bug. Pin
Member 419459316-Jan-15 4:25
Member 419459316-Jan-15 4:25 
General"Cloud computing" make me cringe. Pin
Leng Vang15-Jan-15 7:19
Leng Vang15-Jan-15 7:19 
GeneralRe: "Cloud computing" make me cringe. Pin
Marc Clifton15-Jan-15 7:32
mvaMarc Clifton15-Jan-15 7:32 
GeneralRe: "Cloud computing" make me cringe. Pin
OriginalGriff15-Jan-15 8:02
mveOriginalGriff15-Jan-15 8:02 
GeneralRe: "Cloud computing" make me cringe. Pin
Jörgen Andersson15-Jan-15 8:38
professionalJörgen Andersson15-Jan-15 8:38 
GeneralRe: "Cloud computing" make me cringe. Pin
OriginalGriff15-Jan-15 8:48
mveOriginalGriff15-Jan-15 8:48 
GeneralRe: "Cloud computing" make me cringe. Pin
Mycroft Holmes15-Jan-15 13:53
professionalMycroft Holmes15-Jan-15 13:53 
GeneralRe: "Cloud computing" make me cringe. Pin
Mark_Wallace15-Jan-15 15:16
Mark_Wallace15-Jan-15 15:16 
GeneralRe: "Cloud computing" make me cringe. Pin
ClockMeister16-Jan-15 6:02
professionalClockMeister16-Jan-15 6:02 
GeneralRe: "Cloud computing" make me cringe. Pin
BrainiacV19-Jan-15 5:12
BrainiacV19-Jan-15 5:12 
GeneralRe: "Cloud computing" make me cringe. Pin
Gary R. Wheeler20-Jan-15 5:44
Gary R. Wheeler20-Jan-15 5:44 
GeneralRe: "Cloud computing" make me cringe. Pin
Jörgen Andersson15-Jan-15 8:39
professionalJörgen Andersson15-Jan-15 8:39 
GeneralRe: "Cloud computing" make me cringe. Pin
kmoorevs15-Jan-15 9:19
kmoorevs15-Jan-15 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.