<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3AOpcodes%3ASUB</id>
	<title>Z80:Opcodes:SUB - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3AOpcodes%3ASUB"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Opcodes:SUB&amp;action=history"/>
	<updated>2026-05-02T14:26:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=Z80:Opcodes:SUB&amp;diff=307&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Opcodes:SUB&amp;diff=307&amp;oldid=prev"/>
		<updated>2016-02-05T22:31:33Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sub stands for subtract but only takes one input.  It subtracts the input from the accumulator and writes back to it.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
    sub op8		;8 bit&lt;br /&gt;
&lt;br /&gt;
=== Allowed Instructions ===&lt;br /&gt;
&lt;br /&gt;
    sub a&lt;br /&gt;
    sub b&lt;br /&gt;
    sub c&lt;br /&gt;
    sub d&lt;br /&gt;
    sub e&lt;br /&gt;
    sub h&lt;br /&gt;
    sub l&lt;br /&gt;
    sub n		;8 bit constant&lt;br /&gt;
    &lt;br /&gt;
    sub (hl)&lt;br /&gt;
    sub (ix+n)&lt;br /&gt;
    sub (iy+n)&lt;br /&gt;
&lt;br /&gt;
== Effects ==&lt;br /&gt;
&lt;br /&gt;
N flag set, P/V is overflow, rest modified by definition.&lt;br /&gt;
&lt;br /&gt;
== Uses ==&lt;br /&gt;
&lt;br /&gt;
Allows you to subtract two 8 bit integers. Useful in if you have an offset and want to eliminate certain items.&lt;br /&gt;
&lt;br /&gt;
    noGood:&lt;br /&gt;
     bcall(_GetKey)&lt;br /&gt;
     sub kAdd		;get rid of all keys above add&lt;br /&gt;
     jr nc,noGood&lt;br /&gt;
&lt;br /&gt;
== T-States ==&lt;br /&gt;
&lt;br /&gt;
r denotes 8-bit register.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
| r || 4 &lt;br /&gt;
|-&lt;br /&gt;
| X || 7 &lt;br /&gt;
|-&lt;br /&gt;
| (hl) || 7 &lt;br /&gt;
|-&lt;br /&gt;
| (ix+X) || 19 &lt;br /&gt;
|-&lt;br /&gt;
| (iy+X) || 19 &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[[Z80:Opcodes:ADC|ADC]],[[Z80:Opcodes:ADD|ADD]],[[Z80:Opcodes:DAA|DAA]],[[Z80:Opcodes:DEC|DEC]],[[Z80:Opcodes:INC|INC]],[[Z80:Opcodes:SBC|SBC]]&lt;br /&gt;
&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
[[Category:Z80 Assembly]]&lt;br /&gt;
[[Category:Z80 Heaven]]&lt;br /&gt;
[[Category:Z80 Opcodes]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>