Doc Bot

Download | Tutorials | Instruction Set | Hardware Reference
Introduction | About Doc Bot | Site Map | Search | Use License | Contact Us
Download
Screenshots
Table Of Contents | Addressing Modes | Memory Model | External Ports | Instruction Set | Hardware Reference | Turn Cycles | File format
Table Of Contents | Introduction | Types Of Memory | Special Function Registers | Basic Registers | Addressing Modes | Program Flow | Timers | External Ports | Interrupts | Power Control Modes | Hardware Components
Table Of Contents | Calculate Square Roots | Safe Division

Documentation

small logo

Math Instructions

ADD (#|&|@|R|@R)op1 (#|&|@|R|@R)op2
  • Opcode: 0x24
  • Addresses: 3
  • Flags: C, OV
  • Registers: none
  • Function: Add op2 to op1
ADDC (#|&|@|R|@R)op1 (#|&|@|R|@R)op2
  • Opcode: 0x34
  • Addresses: 3
  • Flags: C, OV
  • Registers: none
  • Function: Add op2 to op1 with carry

Adds the value of op1 and op2 and stores the result in the memory address pointed to by op1. ADDC also adds the value of the Carry Flag (C) to the result. The Carry Flag (C) is set if the result is greater than 0xFFFF, otherwise it is cleared. The Overflow Flag (OV) is set if the result is outside the signed integer range (-32,768 to 32,767), otherwise it is cleared.

SUBB (#|&|@|R|@R)op1 (#|&|@|R|@R)op2
  • Opcode: 0x94
  • Addresses: 3
  • Flags: C, OV
  • Registers: none
  • Function: Substract op2 from op1

Substracts the value of op2 from that of op1 and stores the result in the memory address pointed to by op1. Note that the operation perfomed is op1 - op2. The Carry Flag (C) is set if op2 is greater than op1, and op1 receives a wrap-around (the result + 0xFFFF); otherwise C is cleared. The Overflow Flag (OV) is set if the result is outside the signed integer range (-32,768 to 32,767), otherwise it is cleared.

MUL (#|&|@|R|@R)op1 (#|&|@|R|@R)op2
  • Opcode: 0xA4
  • Addresses: 3
  • Flags: C, OV
  • Registers: B
  • Function: Multiply op1 by op2

Multiplies the values of op1 and op2 and stores the result in the memory address pointed to by op1. If the result of the multiplication if greater than 0xFFFF, the higher 2 bytes are stored in the B register and the Overflow Flag (OV) is set, otherwise OV is cleared and 0x0000 is stored in the B register. The Carry Flag (C) is always cleared.

DIV (#|&|@|R|@R)op1 (#|&|@|R|@R)op2
  • Opcode: 0x84
  • Addresses: 3
  • Flags: C, OV
  • Registers: B
  • Function: Divide op1 by op2

Divides the value of op1 by that of op2 and stores the result in the memory address pointed to by op1. The remainder of the operation is stored in the B register. Note that the operation perfomed is op1 / op2. Note that this is an integer division, with no fractional part. The Overflow Flag (OV) is set if division by 0 was attempted (and no operation takes place), otherwise it is cleared. The Carry Flag (C) is always cleared.

INC (#|&|@|R|@R)op1
  • Opcode: 0x04
  • Addresses: 2
  • Flags: none
  • Registers: none
  • Function: Increment op1

Increments the value of the memory address pointed to by op1 by 1. If the initial value of op1 was 0xFFFF, it will be reset to 0x0000. This does not set the Carry Flag (C).

DEC (#|&|@|R|@R)op1
  • Opcode: 0x14
  • Addresses: 2
  • Flags: none
  • Registers: none
  • Function: Decrement op1

Decrements the value of the register op1 by 1. If the initial value of op1 was 0x0000, it will be reset to 0xFFFF. This does not set the Carry Flag (C).

Introduction | About Doc Bot | Site Map | Search | Use License | Contact Us
©2009 Daniel Julivert