该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
__declspec(naked) void __stdcall rank(int n)
{
static long array[5] = {1, 2, 3, 4, 5};
static char *format = "%d ";
__asm {
mov esi, [esp+4]
cmp esi, LENGTH array
jge show
push esi
mov eax, esi
mov ebx, OFFSET array
_:
cmp eax, LENGTH array
jge exit
mov ecx, [ebx+esi*4]
mov edx, [ebx+eax*4]
mov [ebx+esi*4], edx
mov [ebx+eax*4], ecx
push esi
push eax
inc esi
push esi
call rank
pop eax
pop esi
mov ecx, [ebx+eax*4]
mov edx, [ebx+esi*4]
mov [ebx+eax*4], edx
mov [ebx+esi*4], ecx
inc eax
jmp _
show:
xor esi, esi
__:
cmp esi, LENGTH array
jge line
push [ebx+esi*4]
push format
call dword ptr [printf]
pop eax
pop eax
inc esi
jmp __
line:
push 10
call dword ptr [putchar]
exit:
pop eax
ret 4
}
}
int main(void)
{
rank(0);
getch();
return 0;
}
------------------------------------------------------
哈 没事 用汇编写了一遍 没仔细检查