exg.s 270 B

12345678910111213141516171819202122
  1. .sect .text; .sect .rom; .sect .data; .sect .bss
  2. .define .exg
  3. ! #bytes in ecx
  4. .sect .text
  5. .exg:
  6. push edi
  7. mov edi,esp
  8. add edi,8
  9. mov ebx,edi
  10. add ebx,ecx
  11. sar ecx,2
  12. 1:
  13. mov eax,(ebx)
  14. xchg eax,(edi)
  15. mov (ebx),eax
  16. add edi,4
  17. add ebx,4
  18. loop 1b
  19. 2:
  20. pop edi
  21. ret