print.s 532 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .sect .text; .sect .rom; .sect .data; .sect .bss
  2. .sect .text
  3. .define printc,printd,prints
  4. ! argument in eax
  5. ! uses ebx
  6. prints:
  7. xchg eax,ebx
  8. 1:
  9. movb al,(ebx)
  10. inc ebx
  11. testb al,al
  12. jz 2f
  13. call printc
  14. jmp 1b
  15. 2:
  16. ret
  17. ! argument in eax
  18. ! uses ecx and edx
  19. printd:
  20. xor edx,edx
  21. mov ecx,10
  22. div ecx
  23. test eax,eax
  24. jz 1f
  25. push edx
  26. call printd
  27. pop edx
  28. 1:
  29. xchg eax,edx
  30. addb al,'0'
  31. ! argument in eax
  32. printc:
  33. push eax
  34. mov ebx,esp
  35. mov eax,1
  36. push eax
  37. push ebx
  38. push eax
  39. call __write
  40. pop ebx
  41. pop ebx
  42. pop ebx
  43. pop ebx
  44. ret