author: bocianu bocianu@gmail.com
Set of procedures to cover Math API functionality.
WARNING!
This library uses 15 bytes on ZP ($F0-$FE)
More about Neo6502:
https://www.olimex.com/Products/Retro-Computers/Neo6502/open-source-hardware
https://www.neo6502.com/
API documentation can be found here:
https://github.com/paulscottrobson/neo6502-firmware/wiki
It's work in progress, so please report any bugs you will find.
name: | value: | description: |
---|---|---|
N6502MSG_ADDRESS | $ff00 | |
MATHAdd | 0 | Add |
MATHSub | 1 | Subtract |
MATHMul | 2 | Multiply |
MATHFDiv | 3 | Float Divide |
MATHIDiv | 4 | Int Divide |
MATHMod | 5 | Int Modulus |
MATHCmp | 6 | Compare |
MATHPow | 7 | Power |
MATHDist | 8 | Distance (counter-rectangle) |
MATHNeg | 16 | Unary Negate |
MATHFlr | 17 | Floor (integer part) |
MATHSqr | 18 | Square root |
MATHSin | 19 | Sine |
MATHCos | 20 | Cosine |
MATHTan | 21 | Tangent |
MATHATan | 22 | Arc Tangent |
MATHExp | 23 | Exponent |
MATHLog | 24 | Logarithm (e) |
MATHAbs | 25 | Absolute value |
MATHSgn | 26 | Sign |
MATHFRnd | 27 | Random (float) |
MATHIRnd | 28 | Random (integer) |
MATHProcessDecimal | 32 | Append BCD encoded decimal digits, convert to float |
MATHConvertStringToNumber | 33 | String to int/float |
MATHConvertNumberToString | 34 | int/float to string |
MATHSetDegRad | 35 | Sets the use of degrees (the default) when non zero, radians when zero. |
STACK_SIZE | 2 | binary operations stack size |
VAR_ADDRESS | $F0 | unary operations variable address (5 bytes) |
STACK_ADDRESS | $F5 | binary operations stack address (STACK_SIZE * 5 bytes) |
name: | address: | type: | description: |
---|---|---|---|
m_integer | VAR_ADDRESS+1 | integer | integer value returned from unary operations |
m_float | VAR_ADDRESS+1 | float | float value returned from unary operations |
name: | description: |
---|---|
SetMathStack | procedure SetMathStack(v:float;i:byte);assembler;overload;register;Inserts float value to the Math stack at the specified position.
parameters: |
SetMathStack | procedure SetMathStack(v:integer;i:byte);assembler;overload;register;Inserts integer value to the Math stack at the specified position.
parameters: |
GetMathStackFloat | function GetMathStackFloat:float;assembler;Returns float value from Math stack at position 0
returns: |
GetMathStackInt | function GetMathStackInt:integer;assembler;Returns integer value from Math stack at position 0
returns: |
IsFloatOnStack | function IsFloatOnStack(i:byte):boolean;Returns true if at desired position on the Math Stack float value is found.
parameters:returns: |
IsFloatVal | function IsFloatVal:boolean;Returns true if float value is located at MathVar.
returns: |
SetMathVar | procedure SetMathVar(v:integer);overload;assembler;register;Sets integer value as the MathVar (operation register for unary)
parameters: |
SetMathVar | procedure SetMathVar(v:float);overload;assembler;register;Sets float value as the MathVar (operation register for unary)
parameters: |
DoMathOnStack | procedure DoMathOnStack(cmd:byte);register;Perform selected operation on the MathStack
parameters: |
DoMathOnVar | procedure DoMathOnVar(cmd:byte);register;Perform selected operation on the MathVar
parameters: |
AddFractionalBCD | function AddFractionalBCD(v0:float;bcd:pointer):float;Adds fractional part to the float variable
parameters:returns: |
NeoIntRandom | function NeoIntRandom(range:integer):integer;Returns an random integer value in the specified range.
parameters:returns: |
NeoFloatRandom | function NeoFloatRandom():float;Returns a random floating point value in the range 0..1
returns: |
NeoStr | procedure NeoStr(i:integer;var s:string);overload;Converts integer value into string variable (size is returned in the first byte)
parameters: |
NeoStr | procedure NeoStr(i:float;var s:string);overload;Converts float value into string variable (size is returned in the first byte)
parameters: |
NeoParseInt | function NeoParseInt(var s:string):integer;Parses string into integer value.
parameters:returns: |
NeoParseFloat | function NeoParseFloat(var s:string):float;Parses string into float value.
parameters:returns: |
SetDegreeMode;assembler;inline | procedure SetDegreeMode;assembler;inline;Sets the use of degrees. |
SetRadianMode;assembler;inline | procedure SetRadianMode;assembler;inline;Sets the use of radians. |