exg.s 251 B

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