Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data:
- names DWORD "A", 0
- DWORD "B", 0
- DWORD "C", 0
- marks DWORD 78,99,95
- ;------------------------------------
- .code:
- INVOKE SortStudents, marks, names, 3
- ;------------------------------------
- SortStudents PROC USES eax ecx esi ebx,
- marks:PTR DWORD, names:PTR DWORD ,Count:DWORD
- mov ecx,Count
- dec ecx ; decrement count by 1
- L1: push ecx ; save outer loop count
- mov esi,marks ; point to first value of marks array
- mov ebx,names ; point to first value of names array
- L2: mov eax,[esi] ; get mark
- cmp [esi+4],eax ; compare mark with the next mark
- jge L3 ; if [esi] <= [edi], skip
- xchg eax,[esi+4] ; exchange mark
- xchg ebx,[ebx+4] ; exchange name
- mov [esi],eax
- L3: add esi,4 ; move marks pointer to the next mark
- add ebx,4 ; move names pointer to the next name
- loop L2 ; inner loop
- pop ecx ; retrieve outer loop count
- loop L1 ; else repeat outer loop
- L4: ret
- SortStudents ENDP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement