Initial commit
This commit is contained in:
160
test.S
Normal file
160
test.S
Normal file
@@ -0,0 +1,160 @@
|
||||
extern printfd
|
||||
extern puts
|
||||
global ack
|
||||
ack:
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
mov ebp, esp
|
||||
mov ebx, [ebp + 20]
|
||||
cmp ebx, 0
|
||||
sete bl
|
||||
test bl, bl
|
||||
jz .le0
|
||||
mov ebx, [ebp + 24]
|
||||
add ebx, 1
|
||||
mov eax, ebx
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
jmp .lE0
|
||||
.le0:
|
||||
mov ebx, [ebp + 24]
|
||||
cmp ebx, 0
|
||||
sete bl
|
||||
test bl, bl
|
||||
jz .l0e0
|
||||
mov ebx, [ebp + 20]
|
||||
sub ebx, 1
|
||||
push 1
|
||||
push ebx
|
||||
call ack
|
||||
add esp, 8
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
jmp .lE0
|
||||
.l0e0:
|
||||
mov ebx, [ebp + 20]
|
||||
sub ebx, 1
|
||||
mov eax, [ebp + 24]
|
||||
sub eax, 1
|
||||
push eax
|
||||
push dword [ebp + 20]
|
||||
call ack
|
||||
add esp, 8
|
||||
push eax
|
||||
push ebx
|
||||
call ack
|
||||
add esp, 8
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
.lE0:
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
global foo
|
||||
foo:
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
mov ebp, esp
|
||||
mov ebx, dword [ebp + 20]
|
||||
mov eax, dword [ebp + 20]
|
||||
mov eax, [eax]
|
||||
add eax, 1
|
||||
mov dword [ebx], eax
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
global main
|
||||
main:
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
mov ebp, esp
|
||||
sub esp, 12
|
||||
mov dword [ebp - 4], 0
|
||||
.l0:
|
||||
mov ebx, [ebp - 4]
|
||||
cmp ebx, 4
|
||||
sete bl
|
||||
test bl, bl
|
||||
jnz .le0
|
||||
mov dword [ebp - 8], 0
|
||||
.l1:
|
||||
mov ebx, [ebp - 8]
|
||||
cmp ebx, 4
|
||||
sete bl
|
||||
test bl, bl
|
||||
jnz .le1
|
||||
push dword [ebp - 8]
|
||||
push dword [ebp - 4]
|
||||
call ack
|
||||
add esp, 8
|
||||
push eax
|
||||
call printfd
|
||||
add esp, 4
|
||||
lea ebx, dword [ebp - 8]
|
||||
push ebx
|
||||
call foo
|
||||
add esp, 4
|
||||
jmp .l1
|
||||
.le1:
|
||||
mov ebx, [ebp - 4]
|
||||
add ebx, 1
|
||||
mov dword [ebp - 4], ebx
|
||||
jmp .l0
|
||||
.le0:
|
||||
mov ebx, [ebp + 20]
|
||||
mov dword [ebp - 8], ebx
|
||||
mov ebx, [ebp + 24]
|
||||
mov dword [ebp - 12], ebx
|
||||
.l2:
|
||||
mov ebx, [ebp - 8]
|
||||
cmp ebx, 0
|
||||
sete bl
|
||||
mov eax, dword [ebp - 12]
|
||||
mov eax, [eax]
|
||||
cmp eax, 0
|
||||
sete al
|
||||
or bl, al
|
||||
test bl, bl
|
||||
jnz .le2
|
||||
mov ebx, dword [ebp - 12]
|
||||
push dword [ebx]
|
||||
call puts
|
||||
add esp, 4
|
||||
mov ebx, [ebp - 8]
|
||||
sub ebx, 1
|
||||
mov dword [ebp - 8], ebx
|
||||
mov ebx, [ebp - 12]
|
||||
add ebx, 4
|
||||
mov dword [ebp - 12], ebx
|
||||
jmp .l2
|
||||
.le2:
|
||||
mov esp, ebp
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
Reference in New Issue
Block a user