The eZ8 has some very basic math instructions: Add, subtract, increment, decrement, compare, and multiply. The eZ8 does not have an instruction for Division. Instead use a Division Routine. There also your standard bitmath instructions: And, Or, exclusive Or, Complement(not), Rotate, Shift, Bit set.

In this article the regular math instructions will be covered.

Assembly Mnemonic |
Symbolic Operation |

ADC dst,src | dst ← dst + src + C |

ADCX dst,src | allows for extended addressing |

ADD dst,src | dst ← dst + src |

ADDX dst,src | allows for extended addressing |

ADD adds two values. To use it:

add R0,R1; R0 = R0 + R1 add R0,#5; R0 = R0 + 5

ADC adds two values + carry. Use it to add 16 bit numbers for example. To use it:

;Add an 8 bit number to a 16 bit value. ;First add the lower bytes and then add 0 +carry to the higher byte add R1,R3; Notice the order of the additions! adc R0,#0; R1 is the lower byte or register pair RR0 ;Add an 8 bit value to a 16 bit value. ;First add the lower bytes and then add the higher bytes with carry. add R1,R3 adc R0,R2

Assembly Mnemonic |
Symbolic Operation |

SBC dst,src | dst ← dst - src - C |

SBCX dst,src | allows for extended addressing |

SUB dst,src | dst ← dst - src |

SUBX dst,src | allows for extended addressing |

SUB subtracts two values. To use it:

sub R0,R1; R0 = R0 - R1 sub R0,#5; R0 = R0 - 5

SBC subtracts two values - carry. Use it to subtract 16 bit numbers for example. To use it:

;Subtract an 8 bit number from a 16 bit value. ;First subtract the lower bytes and then subtract carry from the higher byte. sub R1,R3; Notice the order of the subtractions! sbc R0,#0; R1 is the lower byte or register pair RR0 ;Subtract a 16 bit value from a 16 bit value. ;First subtract the lower bytes and then subtract the higher bytes with carry. sub R1,R3 sbc R0,R2

Assembly Mnemonic |
Symbolic Operation |

INC dst | dst ← dst + 1 |

INCW dst | same but for a register pair |

DEC dst | dst ← dst - 1 |

DECW dst | same but for a register pair |

INC/INCW increments register value by 1. To use it:

;increment register R2 inc R2 ;increment register pair RR0 incw RR0

DEC/DECW decrements register value by 1. To use it:

;decrement register R2 dec R2 ;decrement register pair RR0 decw RR0

Comparing two values is like subtraction but without affecting any registers other than the flags register. By looking at the flags you can see if the compared values are equal or unequal, greater or smaller. The Jump Instructions check the flags if you specify a condition code.

Assembly Mnemonic |
Symbolic Operation |

CP dst,src | dst - src |

CPX dst,src | allows for extended addressing |

CPC dst,src | dst - src - C |

CPCX dst,src | allows for extended addressing |

The eZ8 has a multiplication instruction which is really helpful. Not all cpu have a multiplication instruction because it requires a lot of transistors.

Assembly Mnemonic |
Symbolic Operation |

MULT dst | dst[15..0] ← dst[15..8] * dst[7..0] |

MULT multiplies the lower by the higher byte from a register pair and stores it back in the register pair. To use:

ld R0,#37 ld R1,#20 mult RR0 ; Multiplies R0 by R1 and stores the 16 bit result in pair RR0 ; in this case the result is 740 ; register R1 contains the lower portion of this number ; register R0 contains the HIGHER portion of this number

*Please submit corrections, suggestions, and new documentation here: Submit a ticket*

← Return to Reference Index

This is not an official Zilog website. Zilog nor 8times8 are liable for any damage done to equipment. Tutorial and reference copyright ©8times8 Creative Commons CC-0 License (public domain.) This reference uses content from Zilog's technical datasheets. Fair use only. Datasheets copyright © 2013 Zilog^{®}, Inc. Z8, Z8 Encore!, Z8 Encore! XP and Z8 Encore! MC are trademarks or registered trademarks of Zilog, Inc. Read Zilog's terms at zilog.com

Website design by Koen van Vliet. Hosted by sourceforge.net