sgn.asm 850 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ; Returns SGN (SIGN) for 32, 16 and 8 bits signed integers, Fixed and FLOAT
  2. ;- PROC
  3. ;- LOCAL __ENDSGN
  4. __SGNF:
  5. ora z80_b ;- or b
  6. ora z80_c ;- or c
  7. ora z80_d ;- or d
  8. ora z80_e ;- or e
  9. bne *+3 ;- ret z
  10. rts
  11. lda z80_e ;- ld a,e
  12. sta z80_a
  13. jmp __ENDSGN ;- jr __ENDSGN
  14. __SGNF16:
  15. __SGNI32:
  16. lda z80_h ;- ld a,h
  17. sta z80_a
  18. ora z80_l ;- or l
  19. ora z80_e ;- or e
  20. ora z80_d ;- or d
  21. bne *+3 ;- ret z
  22. rts
  23. lda z80_d ;- ld a,d
  24. sta z80_a
  25. jmp __ENDSGN ;- jr __ENDSGN
  26. __SGNI16:
  27. lda z80_h ;- ld a,h
  28. sta z80_a
  29. ora z80_l ;- or l
  30. bne *+3 ;- ret z
  31. rts
  32. lda z80_h ;- ld a,h
  33. sta z80_a
  34. __ENDSGN:
  35. ora z80_a ;- or a
  36. lda #1 ;- ld a,1
  37. sta z80_a
  38. bmi *+3 ;- ret p
  39. rts
  40. eor #$ff ;- neg
  41. clc
  42. adc #$01
  43. rts ;- ret
  44. ;- ENDP