_inn2.s 685 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. ! $Source$
  3. ! $State$
  4. ! $Revision$
  5. ! Declare segments (the order is important).
  6. .sect .text
  7. .sect .rom
  8. .sect .data
  9. .sect .bss
  10. ! Bit test on 16 bits set
  11. ! Expects on stack: bit number
  12. ! set to be tested
  13. ! Yields in de-registers: 0 if bit is reset or bit number out of range
  14. ! 1 if bit is set
  15. .sect .text
  16. .define .inn2
  17. .inn2: pop h
  18. shld .retadr
  19. pop d !bit number
  20. pop h !set to be tested
  21. mov a,e
  22. cpi 16
  23. jnc 3f
  24. cpi 8
  25. jnc 1f
  26. mov e,a
  27. mov a,l !l-reg contains the wanted bit
  28. jmp 2f
  29. 1: sbi 8
  30. mov e,a
  31. mov a,h !h-reg contains the wanted bit
  32. 2: dcr e
  33. jm 4f
  34. rar
  35. jmp 2b
  36. 3: xra a !return 0 if bit number out of range
  37. 4: ani 1
  38. mov e,a
  39. mvi d,0
  40. lhld .retadr
  41. pchl