z80:Opcodes:SUB

From Learn @ Cemetech
Revision as of 22:31, 5 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Sub stands for subtract but only takes one input. It subtracts the input from the accumulator and writes back to it.

Syntax

   sub op8		;8 bit

Allowed Instructions

   sub a
   sub b
   sub c
   sub d
   sub e
   sub h
   sub l
   sub n		;8 bit constant
   
   sub (hl)
   sub (ix+n)
   sub (iy+n)

Effects

N flag set, P/V is overflow, rest modified by definition.

Uses

Allows you to subtract two 8 bit integers. Useful in if you have an offset and want to eliminate certain items.

   noGood:
    bcall(_GetKey)
    sub kAdd		;get rid of all keys above add
    jr nc,noGood

T-States

r denotes 8-bit register.

r 4
X 7
(hl) 7
(ix+X) 19
(iy+X) 19

See Also

ADC,ADD,DAA,DEC,INC,SBC