Skip to content

Instantly share code, notes, and snippets.

@kanryu
Created November 13, 2012 16:25
Show Gist options
  • Select an option

  • Save kanryu/4066755 to your computer and use it in GitHub Desktop.

Select an option

Save kanryu/4066755 to your computer and use it in GitHub Desktop.
Compiled asm from gist:4066750 by Visual Studio 2010
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01
include listing.inc
INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES
CONST SEGMENT
$SG5352 DB 'value=%llx', 0aH, 00H
ORG $+4
$SG5354 DB 'x=%llx', 0aH, 00H
CONST ENDS
PUBLIC __real@43e0000000000000
PUBLIC __real@3ff0000000000000
PUBLIC __real@3fe0000000000000
PUBLIC __real@4000000000000000
PUBLIC __real@43f0000000000000
PUBLIC wmain
EXTRN __imp_printf:PROC
EXTRN _fltused:DWORD
EXTRN _RTC_Shutdown:PROC
EXTRN _RTC_InitBase:PROC
pdata SEGMENT
$pdata$wmain DD imagerel $LN7
DD imagerel $LN7+232
DD imagerel $unwind$wmain
pdata ENDS
xdata SEGMENT
$unwind$wmain DD 022101H
DD 0700a720eH
xdata ENDS
; COMDAT __real@43e0000000000000
; File h:\home\src\vcpp\bitwizenot\bitwizenot\bitwizenot.cpp
CONST SEGMENT
__real@43e0000000000000 DQ 043e0000000000000r ; 9.22337e+018
CONST ENDS
; COMDAT __real@3ff0000000000000
CONST SEGMENT
__real@3ff0000000000000 DQ 03ff0000000000000r ; 1
CONST ENDS
; COMDAT __real@3fe0000000000000
CONST SEGMENT
__real@3fe0000000000000 DQ 03fe0000000000000r ; 0.5
CONST ENDS
; COMDAT __real@4000000000000000
CONST SEGMENT
__real@4000000000000000 DQ 04000000000000000r ; 2
CONST ENDS
; COMDAT __real@43f0000000000000
CONST SEGMENT
__real@43f0000000000000 DQ 043f0000000000000r ; 1.84467e+019
CONST ENDS
; COMDAT rtc$TMZ
rtc$TMZ SEGMENT
_RTC_Shutdown.rtc$TMZ DQ FLAT:_RTC_Shutdown
rtc$TMZ ENDS
; COMDAT rtc$IMZ
rtc$IMZ SEGMENT
_RTC_InitBase.rtc$IMZ DQ FLAT:_RTC_InitBase
; Function compile flags: /Odtp /RTCsu
rtc$IMZ ENDS
_TEXT SEGMENT
value$ = 32
x$ = 40
tv72 = 48
argc$ = 80
argv$ = 88
wmain PROC
; 9 : {
$LN7:
mov QWORD PTR [rsp+16], rdx
mov DWORD PTR [rsp+8], ecx
push rdi
sub rsp, 64 ; 00000040H
mov rdi, rsp
mov ecx, 16
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, DWORD PTR [rsp+80]
; 10 : uint64_t value = ~0ULL;
mov QWORD PTR value$[rsp], -1
; 11 : printf("value=%llx\n", value);
mov rdx, QWORD PTR value$[rsp]
lea rcx, OFFSET FLAT:$SG5352
call QWORD PTR __imp_printf
; 12 : uint64_t x = (value == ~0ULL ? ~0ULL : (value / 2.0 + .5+1));
cmp QWORD PTR value$[rsp], -1
jne SHORT $LN3@wmain
movsdx xmm0, QWORD PTR __real@43f0000000000000
movsdx QWORD PTR tv72[rsp], xmm0
jmp SHORT $LN4@wmain
$LN3@wmain:
mov rax, QWORD PTR value$[rsp]
pxor xmm0, xmm0
cvtsi2sd xmm0, rax
test rax, rax
jge SHORT $LN6@wmain
addsd xmm0, QWORD PTR __real@43f0000000000000
$LN6@wmain:
divsd xmm0, QWORD PTR __real@4000000000000000
addsd xmm0, QWORD PTR __real@3fe0000000000000
addsd xmm0, QWORD PTR __real@3ff0000000000000
movsdx QWORD PTR tv72[rsp], xmm0
$LN4@wmain:
xor eax, eax
movsdx xmm0, QWORD PTR tv72[rsp]
comisd xmm0, QWORD PTR __real@43e0000000000000
jbe SHORT $LN5@wmain
subsd xmm0, QWORD PTR __real@43e0000000000000
comisd xmm0, QWORD PTR __real@43e0000000000000
jae SHORT $LN5@wmain
mov rcx, -9223372036854775808 ; 8000000000000000H
add rax, rcx
$LN5@wmain:
cvttsd2si rcx, xmm0
add rcx, rax
mov rax, rcx
mov QWORD PTR x$[rsp], rax
; 13 : //uint64_t x = (value == ~0ULL ? ~0ULL : 4);
; 14 : printf("x=%llx\n", x);
mov rdx, QWORD PTR x$[rsp]
lea rcx, OFFSET FLAT:$SG5354
call QWORD PTR __imp_printf
; 15 : return 0;
xor eax, eax
; 16 : }
add rsp, 64 ; 00000040H
pop rdi
ret 0
wmain ENDP
_TEXT ENDS
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment