Device: Math
The math device provides access to efficient implementations of complex math operations.
Port | Name | Description | Read | Write |
---|---|---|---|---|
0x20 | Operand 1 | Left-hand operand. | ✗ | ✓ |
0x21 | continued | continued | ✗ | ✓ |
0x22 | Operand 2 | Right-hand operand. | ✗ | ✓ |
0x23 | continued | continued | ✗ | ✓ |
0x24 | Square root | Square root. | ✓ | ✗ |
0x25 | continued | continued | ✓ | ✗ |
0x26 | Heading | Heading to a point. | ✓ | ✗ |
0x27 | continued | continued | ✓ | ✗ |
0x28 | Product | Product of multiplication. | ✓ | ✗ |
0x29 | continued | continued | ✓ | ✗ |
0x2A | continued | continued | ✓ | ✗ |
0x2B | continued | continued | ✓ | ✗ |
0x2C | Quotient | Quotient of division. | ✓ | ✗ |
0x2D | continued | continued | ✓ | ✗ |
0x2E | Remainder | Remainder of division. | ✓ | ✗ |
0x2F | continued | continued | ✓ | ✗ |
Ports
Operand 1
Reading from this port group will return the value of the left-hand operand. The initial value of this port is zero.
Writing to this port group will set the value of the left-hand operand.
Operand 2
Reading from this port group will return the value of the right-hand operand. The initial value of this port is zero.
Writing to this port group will set the value of the right-hand operand.
Square root
Reading from this port group will return the integer part of the square root of a 32-bit input value. The high 16 bits of the input value are given by operand 1, and the low 16 bits of the input value are given by operand 2.
Heading
Reading from this port group will return the integer part of the angle measured clockwise between a ray extending from the origin in the positive Y direction and a ray extending from the origin to a point. The horizontal and vertical components of the origin are both zero. The horizontal component of the point is a signed integer given by operand 1, and the vertical component of the point is a signed integer given by operand 2. If operand 1 and operand 2 are both zero, the returned value will be zero.
The unit of the returned value is equal to 1/65536 of a full turn.
Product
Reading from this port group will return the product of the multiplication of operand 1 by operand 2.
Quotient
Reading from this port group will return the quotient of the integer division of operand 1 by operand 2. If operand 2 is zero, the returned value will be zero.
Remainder
Reading from this port group will return the remainder of the integer division of operand 1 by operand 2. If operand 2 is zero, the returned value will be zero.
System wake
This device will never send a wake request to the system device.