Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
1.1KB

  1. jp test
  2. .inc "core.asm"
  3. testNum: .db 1
  4. test:
  5. ld hl, 0xffff
  6. ld sp, hl
  7. ; *** Just little z80 flags memo.
  8. and a ; clear carry
  9. ld hl, 100
  10. ld de, 101
  11. sbc hl, de
  12. jp nc, fail ; carry is set
  13. call nexttest
  14. and a ; clear carry
  15. ld hl, 101
  16. ld de, 100
  17. sbc hl, de
  18. jp c, fail ; carry is reset
  19. call nexttest
  20. ld a, 1
  21. dec a
  22. jp m, fail ; positive
  23. dec a
  24. jp p, fail ; negative
  25. call nexttest
  26. ; *** subHL ***
  27. ld hl, 0x123
  28. ld a, 0x25
  29. call subHL
  30. ld a, h
  31. cp 0
  32. jp nz, fail
  33. ld a, l
  34. cp 0xfe
  35. jp nz, fail
  36. call nexttest
  37. ld hl, 0x125
  38. ld a, 0x23
  39. call subHL
  40. ld a, h
  41. cp 1
  42. jp nz, fail
  43. ld a, l
  44. cp 0x02
  45. jp nz, fail
  46. call nexttest
  47. ld hl, 0x125
  48. ld a, 0x25
  49. call subHL
  50. ld a, h
  51. cp 1
  52. jp nz, fail
  53. ld a, l
  54. cp 0
  55. jp nz, fail
  56. call nexttest
  57. ; *** cpHLDE ***
  58. ld hl, 0x42
  59. ld de, 0x42
  60. call cpHLDE
  61. jp nz, fail
  62. jp c, fail
  63. call nexttest
  64. ld de, 0x4242
  65. call cpHLDE
  66. jp z, fail
  67. jp nc, fail
  68. call nexttest
  69. ld hl, 0x4243
  70. call cpHLDE
  71. jp z, fail
  72. jp c, fail
  73. call nexttest
  74. ; success
  75. xor a
  76. halt
  77. nexttest:
  78. ld a, (testNum)
  79. inc a
  80. ld (testNum), a
  81. ret
  82. fail:
  83. ld a, (testNum)
  84. halt