Skip to content

Instantly share code, notes, and snippets.

@dabroz
Created May 16, 2011 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabroz/974550 to your computer and use it in GitHub Desktop.
Save dabroz/974550 to your computer and use it in GitHub Desktop.
UP
.file "c.cpp"
.intel_syntax noprefix
.def ___main; .scl 2; .type 32; .endef
.text
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
push ebp
mov ebp, esp
and esp, -16
push edi
push esi
push ebx
sub esp, 52
call ___main
mov DWORD PTR [esp], 25165824
call __Znaj
mov DWORD PTR [esp], 25165824
mov ebx, eax
call __Znaj
mov esi, ebx
and esi, 15
shr esi, 2
neg esi
and esi, 3
je L14
xor edx, edx
mov edi, 6291456
.p2align 4,,10
L3:
mov DWORD PTR [ebx+edx*4], edx
mov ecx, edi
inc edx
sub ecx, edx
cmp esi, edx
ja L3
L2:
mov DWORD PTR [esp+44], 6291456
sub DWORD PTR [esp+44], esi
mov edi, DWORD PTR [esp+44]
shr edi, 2
mov DWORD PTR [esp+28], edi
sal edi, 2
mov DWORD PTR [esp+40], edi
test edi, edi
je L17
lea edi, [edx+1]
movd xmm3, edx
mov DWORD PTR [esp+36], edi
lea edi, [edx+2]
mov DWORD PTR [esp+32], edi
lea edi, [edx+3]
movd xmm0, DWORD PTR [esp+32]
movd xmm2, edi
mov DWORD PTR [esp+32], eax
punpckldq xmm0, xmm2
lea edi, [ebx+esi*4]
movd xmm2, DWORD PTR [esp+36]
movq xmm1, xmm0
punpckldq xmm3, xmm2
mov DWORD PTR [esp+36], ebx
movq xmm0, xmm3
movdqa xmm2, XMMWORD PTR LC0
punpcklqdq xmm0, xmm1
xor esi, esi
mov ebx, DWORD PTR [esp+28]
jmp L5
.p2align 4,,10
L15:
movdqa xmm0, xmm1
L5:
mov eax, esi
movdqa xmm1, xmm0
sal eax, 4
inc esi
paddd xmm1, xmm2
movdqa XMMWORD PTR [edi+eax], xmm0
cmp esi, ebx
jb L15
add edx, DWORD PTR [esp+40]
sub ecx, DWORD PTR [esp+40]
mov esi, DWORD PTR [esp+40]
mov ebx, DWORD PTR [esp+36]
mov eax, DWORD PTR [esp+32]
cmp DWORD PTR [esp+44], esi
je L6
.p2align 4,,10
L17:
mov DWORD PTR [ebx+edx*4], edx
inc edx
dec ecx
jne L17
L6:
lea edx, [eax+16]
mov esi, 512
lea edi, [ebx+16]
mov DWORD PTR [esp+44], edx
.p2align 4,,10
L8:
cmp eax, edi
jbe L24
L16:
xor edx, edx
.p2align 4,,10
L11:
movdqu xmm0, XMMWORD PTR [ebx+edx]
movdqu XMMWORD PTR [eax+edx], xmm0
add edx, 16
cmp edx, 25165824
jne L11
dec esi
jne L8
L12:
mov eax, DWORD PTR [eax]
add esp, 52
pop ebx
pop esi
pop edi
leave
ret
L24:
cmp ebx, DWORD PTR [esp+44]
ja L16
xor edx, edx
.p2align 4,,10
L9:
mov ecx, DWORD PTR [ebx+edx*4]
mov DWORD PTR [eax+edx*4], ecx
inc edx
cmp edx, 6291456
jne L9
dec esi
jne L8
jmp L12
L14:
mov ecx, 6291456
xor edx, edx
.p2align 4,,3
jmp L2
.section .rdata,"dr"
.align 16
LC0:
.long 4
.long 4
.long 4
.long 4
.def __Znaj; .scl 2; .type 32; .endef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment