Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;coded by Roger Rotge
- ;July 22, 2011
- ;this is an assembly language version of the bubble sort routine
- section .text
- global _sort
- _sort:
- push ebp
- mov ebp, esp
- sub esp, 16
- mov dword [ebp-2], 0
- jmp L2
- L6:
- mov dword [ebp-8],0
- jmp L3
- L5:
- mov eax, [ebp-8]
- sal eax, 2
- add eax, [ebp+8]
- mov edx, [eax]
- mov eax, [ebp-8]
- inc eax
- sal eax, 2
- add eax, [ebp+8]
- mov eax, [eax]
- cmp edx, eax
- jle L4
- mov eax, [ebp-8]
- sal eax, 2
- add eax, [ebp+8]
- mov eax, [eax]
- mov [ebp-12], eax
- mov eax, [ebp-8]
- sal eax, 2
- add eax, [ebp+8]
- mov edx, [ebp-8]
- inc edx
- sal edx, 2
- add edx, [ebp+8]
- mov edx, [edx]
- mov [eax], edx
- mov eax, [ebp-8]
- inc eax
- sal eax, 2
- add eax, [ebp+8]
- mov edx, [ebp-12]
- mov [eax], edx
- L4:
- inc dword [ebp-8]
- L3:
- mov eax, [ebp+12]
- dec eax
- sub eax, [ebp-4]
- cmp eax, [ebp-8]
- jg L5
- inc dword [ebp-4]
- L2:
- mov eax, [ebp+12]
- dec eax
- cmp eax, [ebp-4]
- jg L6
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement