# z80:Opcodes:SUB

From Learn @ Cemetech

Jump to navigationJump to searchSub 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