123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- IF @Version LT 800
- ECHO MASM version 8.00 or later is strongly recommended.
- ENDIF
- .686
- .XMM
- IF @Version LT 800
- XMMWORD STRUCT 16
- DQ 2 dup (?)
- XMMWORD ENDS
- ENDIF
- .MODEL FLAT
- OPTION DOTNAME
- IF @Version LT 800
- .text$ SEGMENT PAGE 'CODE'
- ELSE
- .text$ SEGMENT ALIGN(64) 'CODE'
- ENDIF
- ALIGN 16
- _OPENSSL_ia32_cpuid PROC PUBLIC
- $L_OPENSSL_ia32_cpuid_begin::
- push ebp
- push ebx
- push esi
- push edi
- xor edx,edx
- pushfd
- pop eax
- mov ecx,eax
- xor eax,2097152
- push eax
- popfd
- pushfd
- pop eax
- xor ecx,eax
- xor eax,eax
- mov esi,DWORD PTR 20[esp]
- mov DWORD PTR 8[esi],eax
- bt ecx,21
- jnc $L000nocpuid
- cpuid
- mov edi,eax
- xor eax,eax
- cmp ebx,1970169159
- setne al
- mov ebp,eax
- cmp edx,1231384169
- setne al
- or ebp,eax
- cmp ecx,1818588270
- setne al
- or ebp,eax
- jz $L001intel
- cmp ebx,1752462657
- setne al
- mov esi,eax
- cmp edx,1769238117
- setne al
- or esi,eax
- cmp ecx,1145913699
- setne al
- or esi,eax
- jnz $L001intel
- mov eax,2147483648
- cpuid
- cmp eax,2147483649
- jb $L001intel
- mov esi,eax
- mov eax,2147483649
- cpuid
- or ebp,ecx
- and ebp,2049
- cmp esi,2147483656
- jb $L001intel
- mov eax,2147483656
- cpuid
- movzx esi,cl
- inc esi
- mov eax,1
- xor ecx,ecx
- cpuid
- bt edx,28
- jnc $L002generic
- shr ebx,16
- and ebx,255
- cmp ebx,esi
- ja $L002generic
- and edx,4026531839
- jmp $L002generic
- $L001intel:
- cmp edi,4
- mov esi,-1
- jb $L003nocacheinfo
- mov eax,4
- mov ecx,0
- cpuid
- mov esi,eax
- shr esi,14
- and esi,4095
- $L003nocacheinfo:
- mov eax,1
- xor ecx,ecx
- cpuid
- and edx,3220176895
- cmp ebp,0
- jne $L004notintel
- or edx,1073741824
- and ah,15
- cmp ah,15
- jne $L004notintel
- or edx,1048576
- $L004notintel:
- bt edx,28
- jnc $L002generic
- and edx,4026531839
- cmp esi,0
- je $L002generic
- or edx,268435456
- shr ebx,16
- cmp bl,1
- ja $L002generic
- and edx,4026531839
- $L002generic:
- and ebp,2048
- and ecx,4294965247
- mov esi,edx
- or ebp,ecx
- cmp edi,7
- mov edi,DWORD PTR 20[esp]
- jb $L005no_extended_info
- mov eax,7
- xor ecx,ecx
- cpuid
- mov DWORD PTR 8[edi],ebx
- $L005no_extended_info:
- bt ebp,27
- jnc $L006clear_avx
- xor ecx,ecx
- DB 15,1,208
- and eax,6
- cmp eax,6
- je $L007done
- cmp eax,2
- je $L006clear_avx
- $L008clear_xmm:
- and ebp,4261412861
- and esi,4278190079
- $L006clear_avx:
- and ebp,4026525695
- and DWORD PTR 8[edi],4294967263
- $L007done:
- mov eax,esi
- mov edx,ebp
- $L000nocpuid:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
- _OPENSSL_ia32_cpuid ENDP
- ;EXTERN _OPENSSL_ia32cap_P:NEAR
- ALIGN 16
- _OPENSSL_rdtsc PROC PUBLIC
- $L_OPENSSL_rdtsc_begin::
- xor eax,eax
- xor edx,edx
- lea ecx,DWORD PTR _OPENSSL_ia32cap_P
- bt DWORD PTR [ecx],4
- jnc $L009notsc
- rdtsc
- $L009notsc:
- ret
- _OPENSSL_rdtsc ENDP
- ALIGN 16
- _OPENSSL_instrument_halt PROC PUBLIC
- $L_OPENSSL_instrument_halt_begin::
- lea ecx,DWORD PTR _OPENSSL_ia32cap_P
- bt DWORD PTR [ecx],4
- jnc $L010nohalt
- DD 2421723150
- and eax,3
- jnz $L010nohalt
- pushfd
- pop eax
- bt eax,9
- jnc $L010nohalt
- rdtsc
- push edx
- push eax
- hlt
- rdtsc
- sub eax,DWORD PTR [esp]
- sbb edx,DWORD PTR 4[esp]
- add esp,8
- ret
- $L010nohalt:
- xor eax,eax
- xor edx,edx
- ret
- _OPENSSL_instrument_halt ENDP
- ALIGN 16
- _OPENSSL_far_spin PROC PUBLIC
- $L_OPENSSL_far_spin_begin::
- pushfd
- pop eax
- bt eax,9
- jnc $L011nospin
- mov eax,DWORD PTR 4[esp]
- mov ecx,DWORD PTR 8[esp]
- DD 2430111262
- xor eax,eax
- mov edx,DWORD PTR [ecx]
- jmp $L012spin
- ALIGN 16
- $L012spin:
- inc eax
- cmp edx,DWORD PTR [ecx]
- je $L012spin
- DD 529567888
- ret
- $L011nospin:
- xor eax,eax
- xor edx,edx
- ret
- _OPENSSL_far_spin ENDP
- ALIGN 16
- _OPENSSL_wipe_cpu PROC PUBLIC
- $L_OPENSSL_wipe_cpu_begin::
- xor eax,eax
- xor edx,edx
- lea ecx,DWORD PTR _OPENSSL_ia32cap_P
- mov ecx,DWORD PTR [ecx]
- bt DWORD PTR [ecx],1
- jnc $L013no_x87
- and ecx,83886080
- cmp ecx,83886080
- jne $L014no_sse2
- pxor xmm0,xmm0
- pxor xmm1,xmm1
- pxor xmm2,xmm2
- pxor xmm3,xmm3
- pxor xmm4,xmm4
- pxor xmm5,xmm5
- pxor xmm6,xmm6
- pxor xmm7,xmm7
- $L014no_sse2:
- DD 4007259865,4007259865,4007259865,4007259865
- DD 2430851995
- $L013no_x87:
- lea eax,DWORD PTR 4[esp]
- ret
- _OPENSSL_wipe_cpu ENDP
- ALIGN 16
- _OPENSSL_atomic_add PROC PUBLIC
- $L_OPENSSL_atomic_add_begin::
- mov edx,DWORD PTR 4[esp]
- mov ecx,DWORD PTR 8[esp]
- push ebx
- nop
- mov eax,DWORD PTR [edx]
- $L015spin:
- lea ebx,DWORD PTR [ecx*1+eax]
- nop
- DD 447811568
- jne $L015spin
- mov eax,ebx
- pop ebx
- ret
- _OPENSSL_atomic_add ENDP
- ALIGN 16
- _OPENSSL_cleanse PROC PUBLIC
- $L_OPENSSL_cleanse_begin::
- mov edx,DWORD PTR 4[esp]
- mov ecx,DWORD PTR 8[esp]
- xor eax,eax
- cmp ecx,7
- jae $L016lot
- cmp ecx,0
- je $L017ret
- $L018little:
- mov BYTE PTR [edx],al
- sub ecx,1
- lea edx,DWORD PTR 1[edx]
- jnz $L018little
- $L017ret:
- ret
- ALIGN 16
- $L016lot:
- test edx,3
- jz $L019aligned
- mov BYTE PTR [edx],al
- lea ecx,DWORD PTR [ecx-1]
- lea edx,DWORD PTR 1[edx]
- jmp $L016lot
- $L019aligned:
- mov DWORD PTR [edx],eax
- lea ecx,DWORD PTR [ecx-4]
- test ecx,-4
- lea edx,DWORD PTR 4[edx]
- jnz $L019aligned
- cmp ecx,0
- jne $L018little
- ret
- _OPENSSL_cleanse ENDP
- ALIGN 16
- _CRYPTO_memcmp PROC PUBLIC
- $L_CRYPTO_memcmp_begin::
- push esi
- push edi
- mov esi,DWORD PTR 12[esp]
- mov edi,DWORD PTR 16[esp]
- mov ecx,DWORD PTR 20[esp]
- xor eax,eax
- xor edx,edx
- cmp ecx,0
- je $L020no_data
- $L021loop:
- mov dl,BYTE PTR [esi]
- lea esi,DWORD PTR 1[esi]
- xor dl,BYTE PTR [edi]
- lea edi,DWORD PTR 1[edi]
- or al,dl
- dec ecx
- jnz $L021loop
- neg eax
- shr eax,31
- $L020no_data:
- pop edi
- pop esi
- ret
- _CRYPTO_memcmp ENDP
- ALIGN 16
- _OPENSSL_instrument_bus PROC PUBLIC
- $L_OPENSSL_instrument_bus_begin::
- push ebp
- push ebx
- push esi
- push edi
- mov eax,0
- lea edx,DWORD PTR _OPENSSL_ia32cap_P
- bt DWORD PTR [edx],4
- jnc $L022nogo
- bt DWORD PTR [edx],19
- jnc $L022nogo
- mov edi,DWORD PTR 20[esp]
- mov ecx,DWORD PTR 24[esp]
- rdtsc
- mov esi,eax
- mov ebx,0
- clflush DWORD PTR [edi]
- DB 240
- add DWORD PTR [edi],ebx
- jmp $L023loop
- ALIGN 16
- $L023loop:
- rdtsc
- mov edx,eax
- sub eax,esi
- mov esi,edx
- mov ebx,eax
- clflush DWORD PTR [edi]
- DB 240
- add DWORD PTR [edi],eax
- lea edi,DWORD PTR 4[edi]
- sub ecx,1
- jnz $L023loop
- mov eax,DWORD PTR 24[esp]
- $L022nogo:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
- _OPENSSL_instrument_bus ENDP
- ALIGN 16
- _OPENSSL_instrument_bus2 PROC PUBLIC
- $L_OPENSSL_instrument_bus2_begin::
- push ebp
- push ebx
- push esi
- push edi
- mov eax,0
- lea edx,DWORD PTR _OPENSSL_ia32cap_P
- bt DWORD PTR [edx],4
- jnc $L024nogo
- bt DWORD PTR [edx],19
- jnc $L024nogo
- mov edi,DWORD PTR 20[esp]
- mov ecx,DWORD PTR 24[esp]
- mov ebp,DWORD PTR 28[esp]
- rdtsc
- mov esi,eax
- mov ebx,0
- clflush DWORD PTR [edi]
- DB 240
- add DWORD PTR [edi],ebx
- rdtsc
- mov edx,eax
- sub eax,esi
- mov esi,edx
- mov ebx,eax
- jmp $L025loop2
- ALIGN 16
- $L025loop2:
- clflush DWORD PTR [edi]
- DB 240
- add DWORD PTR [edi],eax
- sub ebp,1
- jz $L026done2
- rdtsc
- mov edx,eax
- sub eax,esi
- mov esi,edx
- cmp eax,ebx
- mov ebx,eax
- mov edx,0
- setne dl
- sub ecx,edx
- lea edi,DWORD PTR [edx*4+edi]
- jnz $L025loop2
- $L026done2:
- mov eax,DWORD PTR 24[esp]
- sub eax,ecx
- $L024nogo:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
- _OPENSSL_instrument_bus2 ENDP
- ALIGN 16
- _OPENSSL_ia32_rdrand_bytes PROC PUBLIC
- $L_OPENSSL_ia32_rdrand_bytes_begin::
- push edi
- push ebx
- xor eax,eax
- mov edi,DWORD PTR 12[esp]
- mov ebx,DWORD PTR 16[esp]
- cmp ebx,0
- je $L027done
- mov ecx,8
- $L028loop:
- DB 15,199,242
- jc $L029break
- loop $L028loop
- jmp $L027done
- ALIGN 16
- $L029break:
- cmp ebx,4
- jb $L030tail
- mov DWORD PTR [edi],edx
- lea edi,DWORD PTR 4[edi]
- add eax,4
- sub ebx,4
- jz $L027done
- mov ecx,8
- jmp $L028loop
- ALIGN 16
- $L030tail:
- mov BYTE PTR [edi],dl
- lea edi,DWORD PTR 1[edi]
- inc eax
- shr edx,8
- dec ebx
- jnz $L030tail
- $L027done:
- xor edx,edx
- pop ebx
- pop edi
- ret
- _OPENSSL_ia32_rdrand_bytes ENDP
- ALIGN 16
- _OPENSSL_ia32_rdseed_bytes PROC PUBLIC
- $L_OPENSSL_ia32_rdseed_bytes_begin::
- push edi
- push ebx
- xor eax,eax
- mov edi,DWORD PTR 12[esp]
- mov ebx,DWORD PTR 16[esp]
- cmp ebx,0
- je $L031done
- mov ecx,8
- $L032loop:
- DB 15,199,250
- jc $L033break
- loop $L032loop
- jmp $L031done
- ALIGN 16
- $L033break:
- cmp ebx,4
- jb $L034tail
- mov DWORD PTR [edi],edx
- lea edi,DWORD PTR 4[edi]
- add eax,4
- sub ebx,4
- jz $L031done
- mov ecx,8
- jmp $L032loop
- ALIGN 16
- $L034tail:
- mov BYTE PTR [edi],dl
- lea edi,DWORD PTR 1[edi]
- inc eax
- shr edx,8
- dec ebx
- jnz $L034tail
- $L031done:
- xor edx,edx
- pop ebx
- pop edi
- ret
- _OPENSSL_ia32_rdseed_bytes ENDP
- .text$ ENDS
- .bss SEGMENT 'BSS'
- COMM _OPENSSL_ia32cap_P:DWORD:4
- .bss ENDS
- .CRT$XCU SEGMENT DWORD PUBLIC 'DATA'
- EXTERN _OPENSSL_cpuid_setup:NEAR
- DD _OPENSSL_cpuid_setup
- .CRT$XCU ENDS
- END
|