sar4.s 528 B

123456789101112131415161718192021222324252627282930313233
  1. .sect .text; .sect .rom; .sect .data; .sect .bss
  2. .sect .text
  3. .define .sar4
  4. .sar4:
  5. ! ebx, descriptor address
  6. ! eax, index
  7. sub eax,(ebx)
  8. mov ecx,8(ebx)
  9. imul ecx
  10. pop ebx
  11. pop edx ! base address
  12. add edx,eax
  13. sar ecx,1
  14. jnb 1f
  15. pop eax
  16. movb (edx),al
  17. jmp ebx
  18. 1:
  19. sar ecx,1
  20. jnb 1f
  21. pop eax
  22. o16 mov (edx),ax
  23. jmp ebx
  24. 1:
  25. xchg edi,edx ! edi = base address, edx is saved edi
  26. mov eax,esi
  27. mov esi,esp
  28. rep movs
  29. mov esp,esi
  30. mov esi,eax
  31. mov edi,edx
  32. jmp ebx