PDA

View Full Version : O2 native functions



ErosOlmi
19-03-2009, 12:33
Dear Charles,

I'm starting to play with O2
Maybe I missed but I do not know which native math commands are present in O2: SIN, COS, RND, ...
Can you please drive me in the right direction?

Thanks a lot
Eros

Charles Pegge
19-03-2009, 13:51
Hi Eros,

I dont have a list yet but you can see which functions are supported in o2glo.bas in the source zip. My ambition is to generate part of the manual directly from the source code in this file.

here is an extract:



'===========================
'>>FLOATING POINT MACRO
' macro function -9
'===========================
data "abs" ,-9, "fabs"
data "acos" ,-9, "fld st(0),st(0) : fmul st(0),st(0) : fld1 : fsubp st(1),st(0) : fchs : fxch st(1) : fpatan"
data "asin" ,-9, "fld st(0),st(0) : fmul st(0),st(0) : fld1 : fsubp st(1),st(0) : fchs : fpatan"
data "atan" ,-9, "fpatan"
data "atn" ,-9, "fld1 : fpatan"
data "cos" ,-9, "fcos"
data "deg" ,-9, "fldpi : fdivp st(1) : push 180 : fimul dword [esp] : add esp,4"
data "frac" ,-9, "sub esp,4 : fstcw [esp] : fstcw [esp+2] : or [esp],0xc00 : fldcw [esp]"+cr+_
"fld st(0) : frndint : fsubp st(1),st(0) : fldcw [esp+2] : add esp,4"
data "hypot" ,-9, "fmul st(0),st(0) : fxch st(1) : fmul st(0),st(0) : faddp st(1) : fsqrt"
data "lin" ,-9, "fldln2 : fxch st(1) : fyl2x"
data "log2" ,-9, "fld1 : fxch st(1) : fyl2x"
data "log10" ,-9, "fldlg2 : fxch st(1) : fyl2x"
data "logn" ,-9, "fld1 : fxch st(1) : fyl2x : fld1 : fdivrp st(1) : fxch st(1) : fyl2x"
data "mod" ,-9, "fxch st(1) : fprem : fstp st(1),st(0)"
data "pi" ,-9, "fldpi"
data "pow" ,-9, powers
data "rad" ,-9, "fldpi : fmulp st(1) : push 180 : fidiv dword [esp] : add esp,4"
data "recip" ,-9, "fld1 : fdivrp"
data "remain" ,-9, "fxch st(1) : fprem"
data "round" ,-9, "frndint"
data "sin" ,-9, "fsin"
data "sincos" ,-9, "fsincos" ' leaves 2 results
data "sqr" ,-9, "fsqrt"
data "sqrt" ,-9, "fsqrt"
data "tan" ,-9, "fptan : fcomp st(0),st(0)"
data "trunc" ,-9, "sub esp,4 : fstcw [esp] : fstcw [esp+2] : or [esp],0xc00 : fldcw [esp]"+cr+_
"frndint : fldcw [esp+2] : add esp,4"
'===========================
...

'===========================
'>>OVERLOADABLE INTEGER AND STRING FUNCTIONS
' overloadable functions -16
' integer and string
' TREATED AS STDCALL
'===========================
data "nuls" ,-16, "##long@0 bstr 52"
data "val" ,-16, "##string@0 double 96 ##astring@0 double 96"
data "ltrim" ,-16, "##string@0 bstr 1156"
data "rtrim" ,-16, "##string@0 bstr 1160"
data "lcase" ,-16, "##string@0 bstr 1164"
data "ucase" ,-16, "##string@0 bstr 1168"
data "string" ,-16, "##long#long@00 bstr 1232 ##long#astring@00 bstr 1236 ##long#string@00 bstr 1240"
data "space" ,-16, "##long@0 bstr 1244"
data "left" ,-16, "##string#long@00 bstr 1172 ##astring#long@00 bstr 1200"
data "mid" ,-16, "##string#long#long@000 bstr 1180 ##astring#long#long@000 bstr 1196 "+cr+_
"##string#long@00 bstr 1208 ##astring#long@00 bstr 1212 "
data "_mid" ,-16, "##long#string@00 long 1228 " ' omit 1st param (assume bstr)
data "instr" ,-16, "##long#string#string@000 long 160 "
data "replace" ,-16, "##string#string#string@000 bstr 164 "
data "getfile" ,-16, "##string@0 bstr 168"
data "putfile" ,-16, "##string#string@00 long 172"
data "print" ,-16, "##string@0 long 1248"
'---------------------------
data "asc" ,-16, "##string@0 long 1216 ##string#long@00 long 1184"
data "len" ,-16, "##string@0 long 1188"
data "chr" ,-16, "##long@0 bstr 1192"
'===========================


'===========================
'>>OVERLOADABLE FLOAT FUNCTIONS
' -17
' floats passed in FPU stack
data "str" ,-17, "##double@0 bstr 100 ##long@0 bstr 100"
data "hex" ,-17, "##double@0 bstr 104 ##long@0 bstr 104"
'===========================





PS: I'm making quite a few adjustments - a new string concatenator went in this morning :).

Not sure what algorithm to use for RND.