ASM Editor home Projects Docs Learn Blog
Donate
Star on github
Z80 Directives Registers & Flags Input/Output Complete documentation

adcaddandbitcallccfcpcpdcpdrcpicpircpldaadecdidjnzeiexexxhaltiminincindindriniinirjpjrldlddlddrldildirnegnoporotdrotiroutoutdoutipoppushresretretiretnrlrlarlcrlcarldrrrrarrcrrcarrdrstsbcscfsetslasllsrasrlsubxor
Create your first project

neg

Negate

Negates A, giving its two's complement, which is the same as subtracting A from zero.

2 bytes·8 cycles

Used in
  • 8-bit and 16-bit arithmetic, logic and bitsZ80 assembly
  • The screen, keyboard and mouse through portsZ80 assembly
  • The bigger of two numbersZ80 assembly
  • A bouncing ballZ80 assembly
SZHP/VNC ●●●●1●
  • ● depends on the result
  • 1 always 1

Forms

  • neg

    Negates A (two's complement), which is the same as subtracting A from zero.

        .org 0x8000
        ld a, 5
        neg
        halt1
2
3
4