print.s 501 B

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