Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data:
  2.     names DWORD "A", 0
  3.           DWORD "B", 0
  4.           DWORD "C", 0
  5.     marks DWORD 78,99,95
  6. ;------------------------------------
  7. .code:
  8.     INVOKE SortStudents, marks, names, 3
  9. ;------------------------------------
  10. SortStudents PROC USES eax ecx esi ebx,
  11.     marks:PTR DWORD, names:PTR DWORD ,Count:DWORD
  12.     mov  ecx,Count
  13.     dec  ecx    ; decrement count by 1
  14. L1: push ecx    ; save outer loop count
  15.     mov  esi,marks  ; point to first value of marks array
  16.     mov  ebx,names  ; point to first value of names array
  17. L2: mov  eax,[esi]  ; get mark
  18.     cmp  [esi+4],eax    ; compare mark with the next mark
  19.     jge  L3 ; if [esi] <= [edi], skip
  20.     xchg eax,[esi+4]    ; exchange mark
  21.     xchg ebx,[ebx+4]    ; exchange name
  22.     mov  [esi],eax
  23. L3: add  esi,4  ; move marks pointer to the next mark
  24.     add  ebx,4 ; move names pointer to the next name
  25.     loop L2 ; inner loop
  26.     pop  ecx    ; retrieve outer loop count
  27.     loop L1 ; else repeat outer loop
  28. L4: ret
  29. SortStudents ENDP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement