<html><head><base href="x-msg://259/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>OK, so no indexed mode? gcc may generate it differently.</div><div><br></div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF"><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Antony Hosking</span></span></font></font><font class="Apple-style-span" face="Gill Sans"><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-converted-space"> </span>|<span class="Apple-converted-space"> </span></span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; ">Associate Professor</span></span><span class="Apple-style-span" style="font-family: 'Gill Sans'; "><span class="Apple-style-span" style="font-family: 'Gill Sans'; "> | Computer Science | Purdue University</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; ">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Office</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "> +1 765 494 6001 |<span class="Apple-converted-space"> </span></span></span></font><font class="Apple-style-span" color="#0000FF" face="Gill Sans"><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; "><span class="Apple-style-span" style="color: rgb(0, 0, 255); font-family: 'Gill Sans'; ">Mobile</span></span></font><font class="Apple-style-span" face="GillSans-Light"><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-style-span" style="font-family: GillSans-Light; "><span class="Apple-converted-space"> </span>+1 765 427 5484</span></span></font></div><div><font class="Apple-style-span" face="GillSans-Light"><br class="khtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="Apple-interchange-newline"></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On 21 Jan 2010, at 04:11, Jay K wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">I tried a few differnt switches.<br>They always seem to get the actual address into a register.<br><br>C:\dev2\cm3.2\m3-sys\m3back\src>type t.c && cl -c -Ox -FAsc t.c && type t.cod<br><br>long __cdecl _InterlockedExchange(long volatile*, long);<br>#pragma intrinsic(_InterlockedIncrement)<br> <br> <br>long __cdecl _InterlockedIncrement(long volatile*);<br>#pragma intrinsic(_InterlockedIncrement)<br> <br> <br>long __cdecl _InterlockedExchangeAdd(long volatile*, long);<br>#pragma intrinsic(_InterlockedExchangeAdd)<br> <br> <br>long __cdecl _InterlockedCompareExchange(long volatile*, long, long);<br>#pragma intrinsic(_InterlockedCompareExchange)<br> <br> <br>long F1(volatile long* a)<br>{<br>return _InterlockedIncrement(&a[10]);<br>}<br> <br><br>typedef struct S1 { int a; long b; } S1;<br>long F2(volatile S1* a)<br>{<br>return _InterlockedExchangeAdd(&a->b, 123);<br>}<br> <br><br>long F3(volatile S1* a)<br>{<br>return _InterlockedCompareExchange(&a->b, 1, 2);<br>}<br> <br><br>long F4(volatile S1* a)<br>{<br>return _InterlockedExchange(&a->b, 1);<br>}<br><br> <br>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86<br>Copyright (C) Microsoft Corporation. All rights reserved.<br>t.c<br>; Listing generated by Microsoft (R) Optimizing Compiler Version 15.00.21022.08<br><br> TITLE C:\dev2\cm3.2\m3-sys\m3back\src\t.c<br> .686P<br> .XMM<br> include listing.inc<br> .model flat<br>INCLUDELIB LIBCMT<br>INCLUDELIB OLDNAMES<br>PUBLIC _F1<br>; Function compile flags: /Ogtpy<br>; File c:\dev2\cm3.2\m3-sys\m3back\src\t.c<br>_TEXT SEGMENT<br>_a$ = 8 ; size = 4<br>_F1 PROC<br>; 15 : return _InterlockedIncrement(&a[10]);<br> 00000 8b 44 24 04 mov eax, DWORD PTR _a$[esp-4]<br> 00004 8d 48 28 lea ecx, DWORD PTR [eax+40]<br> 00007 b8 01 00 00 00 mov eax, 1<br> 0000c f0 0f c1 01 lock xadd DWORD PTR [ecx], eax<br> 00010 40 inc eax<br>; 16 : }<br> 00011 c3 ret 0<br>_F1 ENDP<br>_TEXT ENDS<br>PUBLIC _F2<br>; Function compile flags: /Ogtpy<br>_TEXT SEGMENT<br>_a$ = 8 ; size = 4<br>_F2 PROC<br>; 23 : return _InterlockedExchangeAdd(&a->b, 123);<br> 00020 8b 4c 24 04 mov ecx, DWORD PTR _a$[esp-4]<br> 00024 b8 7b 00 00 00 mov eax, 123 ; 0000007bH<br> 00029 83 c1 04 add ecx, 4<br> 0002c f0 0f c1 01 lock xadd DWORD PTR [ecx], eax<br>; 24 : }<br> 00030 c3 ret 0<br>_F2 ENDP<br>_TEXT ENDS<br>PUBLIC _F3<br>; Function compile flags: /Ogtpy<br>_TEXT SEGMENT<br>_a$ = 8 ; size = 4<br>_F3 PROC<br>; 29 : return _InterlockedCompareExchange(&a->b, 1, 2);<br> 00040 8b 54 24 04 mov edx, DWORD PTR _a$[esp-4]<br> 00044 b9 01 00 00 00 mov ecx, 1<br> 00049 83 c2 04 add edx, 4<br> 0004c b8 02 00 00 00 mov eax, 2<br> 00051 f0 0f b1 0a lock cmpxchg DWORD PTR [edx], ecx<br>; 30 : }<br> 00055 c3 ret 0<br>_F3 ENDP<br>_TEXT ENDS<br>PUBLIC _F4<br>; Function compile flags: /Ogtpy<br>_TEXT SEGMENT<br>_a$ = 8 ; size = 4<br>_F4 PROC<br>; 35 : return _InterlockedExchange(&a->b, 1);<br> 00060 8b 4c 24 04 mov ecx, DWORD PTR _a$[esp-4]<br> 00064 b8 01 00 00 00 mov eax, 1<br> 00069 83 c1 04 add ecx, 4<br> 0006c 87 01 xchg DWORD PTR [ecx], eax<br>; 36 : }<br> 0006e c3 ret 0<br>_F4 ENDP<br>_TEXT ENDS<br>END<br>C:\dev2\cm3.2\m3-sys\m3back\src><br><br><br>probably should try IA64 though.<br> <br> <br> - Jay<br></div></span></blockquote></div><br></body></html>