Mirror of CollapseOS
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

99 satır
1.0KB

  1. jp test
  2. .inc "core.asm"
  3. .inc "lib/util.asm"
  4. .inc "lib/ari.asm"
  5. .inc "lib/fmt.asm"
  6. stdioPutC:
  7. ret
  8. test:
  9. ld sp, 0xffff
  10. call testFmtDecimal
  11. call testFmtDecimalS
  12. ; success
  13. xor a
  14. halt
  15. testFmtDecimal:
  16. ld ix, .t1
  17. call .test
  18. ld ix, .t2
  19. call .test
  20. ld ix, .t3
  21. call .test
  22. ld ix, .t4
  23. call .test
  24. ld ix, .t5
  25. call .test
  26. ret
  27. .test:
  28. ld e, (ix)
  29. ld d, (ix+1)
  30. ld hl, sandbox
  31. call fmtDecimal
  32. ld hl, sandbox
  33. push ix \ pop de
  34. inc de \ inc de
  35. call strcmp
  36. jp nz, fail
  37. jp nexttest
  38. .t1:
  39. .dw 1234
  40. .db "1234", 0
  41. .t2:
  42. .dw 9999
  43. .db "9999", 0
  44. .t3:
  45. .dw 0
  46. .db "0", 0
  47. .t4:
  48. .dw 0x7fff
  49. .db "32767", 0
  50. .t5:
  51. .dw 0xffff
  52. .db "65535", 0
  53. testFmtDecimalS:
  54. ld ix, .t1
  55. call .test
  56. ld ix, .t2
  57. call .test
  58. ret
  59. .test:
  60. ld e, (ix)
  61. ld d, (ix+1)
  62. ld hl, sandbox
  63. call fmtDecimalS
  64. ld hl, sandbox
  65. push ix \ pop de
  66. inc de \ inc de
  67. call strcmp
  68. jp nz, fail
  69. jp nexttest
  70. .t1:
  71. .dw 1234
  72. .db "1234", 0
  73. .t2:
  74. .dw 0-1234
  75. .db "-1234", 0
  76. testNum: .db 1
  77. nexttest:
  78. ld a, (testNum)
  79. inc a
  80. ld (testNum), a
  81. ret
  82. fail:
  83. ld a, (testNum)
  84. halt
  85. ; used as RAM
  86. sandbox: