sscanf.s 625 B

12345678910111213141516171819202122232425262728293031323334
  1. |sscanf() implementation for TIGCCLIB - callback functions
  2. |Copyright (C) Kevin Kofler, 2002-2003
  3. /*Prototypes:
  4. typedef struct {char *buffer; unsigned short pos;} __sscanf_string;
  5. CALLBACK short __sscanf_get(__sscanf_string *param);
  6. CALLBACK void __sscanf_unget(short c, __sscanf_string *param);
  7. */
  8. .text
  9. .xdef __sscanf_get
  10. __sscanf_get:
  11. movea.l 4(%a7),%a0
  12. moveq.l #0,%d1
  13. move.w 4(%a0),%d1
  14. movea.l (%a0),%a1
  15. clr.w %d0
  16. move.b 0(%a1,%d1:l),%d0
  17. beq.s 0f
  18. addq.w #1,4(%a0)
  19. rts
  20. 0:
  21. moveq.l #-1,%d0 |EOF
  22. rts
  23. .xdef __sscanf_unget
  24. __sscanf_unget:
  25. movea.l 6(%a7),%a0
  26. addq.l #4,%a0
  27. tst.w (%a0)
  28. beq.s 1f
  29. subq.w #1,(%a0)
  30. 1:
  31. rts