![]() |
c128lib Base
Base macros for C128
|
Math module. More...
Functions | |
macro | Add16 (value, dest) |
This macro performs a 16-bit addition operation. | |
macro | Sub16 (value, dest) |
This macro performs a 16-bit subtraction operation. | |
macro | Asl16 (address) |
This macro performs a 16-bit arithmetic shift left (ASL) operation. | |
Math module.
Simple macros for math operations.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
macro Add16 | ( | value | , |
dest | ) |
This macro performs a 16-bit addition operation.
The macro uses the 6502 processor's ADC (Add with Carry) instruction to perform the addition. It first clears the carry flag with CLC, then adds the low byte of the value to the low byte at the destination, and stores the result back in the low byte at the destination. It then adds the high byte of the value to the high byte at the destination, taking into account any carry from the low byte addition, and stores the result back in the high byte at the destination.
[in] | value | The 16-bit value to add. |
[in,out] | dest | The memory location of the other 16-bit value. |
macro Sub16 | ( | value | , |
dest | ) |
This macro performs a 16-bit subtraction operation.
The macro uses the 6502 processor's SBC (Subtract with Carry) instruction to perform the subtraction. It first sets the carry flag with SEC, then subtracts the low byte of the value from the low byte at the destination, and stores the result back in the low byte at the destination. It then subtracts the high byte of the value from the high byte at the destination, taking into account any borrow from the low byte subtraction, and stores the result back in the high byte at the destination.
[in] | value | The 16-bit value to subtract. |
[in,out] | dest | The memory location of the other 16-bit value. |
macro Asl16 | ( | address | ) |
This macro performs a 16-bit arithmetic shift left (ASL) operation.
The macro uses the 6502 processor's ASL (Arithmetic Shift Left) instruction to perform the shift. It first shifts the low byte at the value location left, then shifts the high byte at the value location left, taking into account any carry from the low byte shift.
[in,out] | address | The memory location of the 16-bit value to shift left. |