printf.s 427 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. .sect .text; .sect .rom; .sect .data; .sect .bss
  2. .sect .text
  3. .define printf
  4. .extern printc, printd, prints
  5. printf:
  6. pop bx ! return address
  7. xchg ax,di
  8. mov si,sp
  9. 1:
  10. movb al,(di)
  11. inc di
  12. testb al,al
  13. jz 6f
  14. cmpb al,'%'
  15. je 3f
  16. 2:
  17. call printc
  18. jmp 1b
  19. 3:
  20. movb al,(di)
  21. inc di
  22. cmpb al,'c'
  23. jne 4f
  24. lods
  25. jmp 2b
  26. 4:
  27. cmpb al,'d'
  28. jne 5f
  29. lods
  30. call printd
  31. jmp 1b
  32. 5:
  33. cmpb al,'s'
  34. jne 2b
  35. lods
  36. call prints
  37. jmp 1b
  38. 6:
  39. jmp bx