neg16.asm 374 B

123456789101112131415161718192021222324
  1. ; Negates HL value (16 bit)
  2. __ABS16:
  3. lda #$80 ;- bit 7,h
  4. cmp z80_h
  5. bne *+3 ;- ret z
  6. rts
  7. __NEGHL:
  8. lda z80_l ;- ld a,l ; HL = -HL
  9. sta z80_a
  10. eor #$ff ;- cpl
  11. lda z80_a ;- ld l,a
  12. sta z80_l
  13. lda z80_h ;- ld a,h
  14. sta z80_a
  15. eor #$ff ;- cpl
  16. lda z80_a ;- ld h,a
  17. sta z80_h
  18. inc z80_l ;- inc hl
  19. bne *+4
  20. inc z80_h
  21. rts ;- ret