'
'
'
'         ###############
'       ###################
'      ###               ###
'     ###    ###          ###
'    ###    ## ##         ###
'    ###   ##   ##        ###
'    ###  ##     ##       ###
'    ###  ##      ##      ###
'    ###  ##      ##      ###
'    ###   ####  ##      ###
'     ###    ####       ###
'      ###             ###
'       ###           ###
'         #############
'           #########

'LANG.INC


'METATYPES
'=========
'
string metatypes="
  >0   compund variable,
   0   primitive variable or constant,
  -1   shared symbol,
  -2   (unused),
  -3   type / class,
  -4   core RTL proc,
  -5   proc / sub / function / method,
  -6   (unused),
  -7   (unused),
  -8   struct from typedef,
  -9   reserved word,
  -10  x86 register,
  -11  attributes,
  -12  namespace,
  -13  core keyword,
  -14  core keyword,
  -15  primitive type,
  -16  core function,
  -17  core float macro,
  -18  def / equate,
  -19  core def,
  -20  macro,
  -22  internal code macro,
  -30  label,
  -31  number literal,
  -32  string literal,
  -33  enumeration,
"
'also numeric equates


'
'CALLING CONVENTIONS
'===================
'
string callco="
  stdcall 100
  cdecl 101
  ms64 102
  ox64 103
  pascal 108
  thiscall 120
  fastcall 140
"
'

'=========================
'>>OXYGEN LOW LEVEL MACROS
'=========================

#if sizeof sys = 8
  string kernel_funs="version 18 "+qu+o2version+" "+o2datetimestamp+" 64bit"+qu+cr+
  "o2version 18 "+qu+o2version+qu+cr
#else
  string kernel_funs="version 18 "+qu+o2version+" "+o2datetimestamp+" 32bit"+qu+cr+
  "o2version 18 "+qu+o2version+qu+cr
#endif

kernel_funs+=quote ~~~

#snip 18
true  18 -1
false 18 0
cr 18 chr(13,10)
crlf 18 chr(13,10)
qu 18 chr(34)
tab 18 "	"
spc 18 " "
cm 18  ","
infinity 18 1.0/0.0
embed 18 o2 q %1
use 18 include once
uses 18 include once
using 18 include once
global 18 dim static 'global is deprecated
lobyte 18 ((%1) and 0xff)
loword 18 ((%1) and 0xffff)
hibyte 18 (((%1)>>8) and 0xff)
hiword 18 (((%1)>>16) and 0xffff)
chr_ 18 mid_
wchr_ 18 mid_
module 18
module_end 18
interface 18
interface_end 18
internal 18
internal_end 18
#view 18 ###
#endv 18 ###
view 18 print "%1" tab %1
dyn 18  %1 %2 at getmemory( (%3)*sizeof %2 )

stretch 18
  scope
  int _e_=(%2)*sizeof(%1)
  int _l_=*(@%1-4) 'len
  sys _p_=getmemory _e_
  if _e_<_l_ then _l_=_e_
  copy _p_,@%1,_l_
  freememory @%1
  @%1=_p_
  end scope

foreach 18
  scope
  int i
  for i=lbound(%1) to ubound(%1)
    %2
  next
  end scope

on 18
  '%1' name of index variable
  '%2' goto or gosub
  '%3' { @label1,@label2,...}
  scope
  static sys _st_[128]
  if not _st_[1]
    _st_[1]={%3}
  endif
  #if not anymatch " goto gosub call   ","%2"
    #error "Expecting: goto / gosub / call "
  #endif
  %2 _st_[%1]
  end scope


_remap 18
  sys  _mq_
  int* _dac_
  int _le_
  int _lq_
  int _dc_
  int _qb_
  int _qn_
  int _ac_
  int _ib_
  int _i_
  int _e_
  int _k_
  int _dims_[]={%2}
  _dc_=countof()
  _ib_=1-indexbase
  indexbase 1
  _qb_=_dims_[1]+_ib_
  #if ptrlevelof %1>0
    @_dac_=@@%1-12
  #else
    @_dac_=@%1-12
  #endif
  _dac_(0)=_qb_ 'n first term
  _dac_(1)=_dc_ 'dimensions
  _dac_(2)=#minormajor
  _dac_(3)=indexbase
  '
  'ADJUST INDEXBASE
  '
  for _i_=1 to _dc_
     _dims_(_i_)+=_ib_
  next
  '
  'SCALERS AND UBOUNDS
  '
  if #majorminor
    'MAJORMINOR
    _e_=0  'boundary
    _i_=_dc_ 'iterator
    _k_=-1 'stepper
  else
    'MINORMAJOR
    _i_=1
    _e_=_dc_+1
    _k_=1
  endif
  _qb_=1
  do
    if _i_=_e_
      exit do
    endif
    _ac_=-_i_-_i_
    _dac_(_ac_)=_qb_ 'scalers
    _ac_++
    _dac_(_ac_)=_dims_(_i_) 'ubounds
    _qb_*=_dims_(_i_)
    _i_+=_k_
  loop
  _dac_(0)=_qb_


remap 18
  %1  * %2[redim %3] 
  scope
  _remap %2 (%3)
  end scope


redim 18
  #if flagsof(%2) and 16 'prev def
    '%4 clear possible
    '#print "already exists %2"
  #else
    %1  * %2[redim %3]
  #endif
  scope
  _remap %2 (%3)
  _lq_=_qb_*sizeof(%1)
  _le_=0
  if @%2
   _le_=*(@%2-4)
  endif
  _qn_ = _le_ / sizeof(%1)
  #if match "%4","clear"
    for _i_= _qn_ to 1 step -1
      _del(%2[_i_])
    next
  #endif
  if _qb_ > _qn_
    'append
    _mq_=getmemory  _lq_
    if @%2
      copy _mq_,@%2,_le_
      freememory @%2
    endif
    @%2=_mq_
    #if typecodeof(%2)>=0x200
      #if def %2.___
        #if def %1_table
          for _i_=_qn_ +1 to _qb_
            ? %2[_i_] = @%1_table
          next
        #else
          #error "%1 needs %1_table"
        #endif
      #endif
      #if def %2.constructor
        for _i_=_qn_ +1 to _qb_
          %2[_i_].constructor()
        next
      #endif
    #endif
  elseif _qb_ <  _qn_
    for _i_= _qn_ to _qb_ +1 step -1
      _del(%2[_i_])
    next
    _mq_=getmemory _lq_
    if _mq_
      if _qb_ >0
        copy _mq_,@%2,_lq_
      endif
      freememory @%2
      @%2=_mq_
    endif
  endif
  end scope


new 18
  #if match "%4","local"
    local %1 %2
  #elseif match "%4","static"
    static %1 %2
  #else
    %1 * %2
    @%2=getmemory sizeof %1
  #endif
  #if def %2.___
    #if def %1_table
      ? %2 = @%1_table
    #else
      #error "%1 needs %1_table"
    #endif
  #endif
  #if def %2.constructor
    %2.constructor(%3)
  #endif


_del 18
  #if typecodeof(%1)>=0x200
    #if def %1.destructor
      %1.destructor
    #endif
    #if def %1.___
      ?%1=0
    #endif
  #elseif typecodeof(%1)>0xe0
    if ?%1
      freememory strptr(%1)
      if *%1
        *%1=0
      endif
      ?%1=0
    endif
  #elseif typecodeof(%1)>0xc0
    if ?%1 
      freememory strptr(%1)
      ?%1=0
    endif
  #elseif typecodeof(%1)>0xa0
    %1=""
  #elseif typecodeof(%1)>0
    %1=0
  #endif


del 18
  scope
  indexbase 1
  #if typecodeof(%1)>0xc0
    #if flagsof(%1) and 2 'arrays
      int _i_
      for _i_= ubound(%1) to 1 step -1
       _del (%1[_i_])
      next
    #else
      _del %1
    #endif
  #endif
  #if ptrlevelof(%1)>0
    if @%1
      freememory @%1
      @%1=0
    endif
  #endif
  end scope


undim 18
  del %1
  undef %1


'HIGH LEVEL MACROS
'=================

left 20 left(s,i) {mid(s,1,i)}
right 20 right(s,i) {mid(s,-(i))}
guidptr 20 guidptr(s) {byval guidval(guid{},s)}
sinh 20 sinh(x) { ( exp(x)-exp(-(x)) / 2 ) }
cosh 20 cosh(x) { ( exp(x)+exp(-(x)) / 2 ) }
tanh 20 tanh(x) { ( sinh(x)/cosh(x) ) }
asinh 20 asinh(x) { lin( (x) + sqr( (x)*(x) + 1 ) ) }
acosh 20 acosh(x) { lin( (x) + sqr( (x)*(x) - 1 ) ) }
atanh 20 atanh(x) { lin( (1+(x)) / (2*(1-(x))) ) }

void_ 20 void_(a,b,c,d){}

swap 20 swap(a,b,  c){
  typeof(a) c
  c=a
  a=b
  b=c
  }

_diminfo 18
  int *_c_
  #if ptrlevelof %2>0
    @_c_=@@%2-(%3)
  #else
    @_c_=@%2-(%3)
  #endif
  %1=_c_
  undef _c_

dimorder 20 dimorder int(a,b){
  _diminfo a b 8 '2*4
  }
dims 20 dims int(a,b){
  _diminfo a b 12 '3*4
  }
elements 20 elements int(a,b,  c){
  _diminfo a b 16 '4*4
  }
scaler 20 scaler int(a,b,i){
  #if ndef i
   a=1
  #else
    _diminfo  a b (16+(i*8))
  #endif
  }
strider 20 strider int(a,b,i) {
  a=scaler(b,i)*sizeof(b)
  }
lbound 20 lbound int(a,b,i) {
  a=indexbase
  }
ubound 20 ubound int(a,b,i) {
  #if flagsof(b) and 2
    #if ndef i
      a=elements(b)+indexbase-1
    #else
      _diminfo a b (12+(i*8)) 'ubound loc: -16+4
      a+=indexbase-1
    #endif
  #else 'not an array
    a=indexbase
  #endif
  }

_sort_ 20 _sort_ (
  index,count,compare, 'params,
  i,src,dest,stp,sw,kk,bi,bj,ej,ed,ni,nj,sx,dj,sd 'encapsulated
  ) {
  '
  ' index      index array name
  ' count      element count
  ' compare    comparator callback/macro
  sys src  = 0      ' index offset for elements to be compared
  sys dest = 0      ' index offset for merged ordered elements
  sys stp  = 0      ' merge group size X sizeof idx element
  sys sw   = 0      ' flag to select from second group instead of first
  sys kk   = 0      ' element counter
  sys bi   = 0      ' base for first group
  sys bj   = 0      ' base for second group
  sys ej   = 0      ' boundary for second group
  sys ed   = 0      ' source data boundary
  int sx   = 4      ' element sizeof int
  int * ni          ' position for first compare element
  int * nj          ' position for second compare element
  int * dj          ' destination for element
  sys sd=count*sx   ' size of index data (bytes)
  '
  src=@index
  dest=sd+@index
  stp=sx 'INITIAL STRIDE IS SIZE OF IDX ELEMENT
  do 'MERGING LOOP
    if stp>=sd
      if src<>@index 'COPY INDEX VALUES BACK TO BASE
        copy @index, @index+sd, sd
      endif
      exit do 'DONE
    endif
    kk=0
    bi=src : bj=bi+stp : ej=bj+stp
    @ni=bi : @nj=bj
    ed=src+sd 'DATA BOUNDARY
    if ej>ed
      ej=ed
    endif
    @dj=dest
    stp+=stp 'DOUBLE STRIDE FOR EACH MERGE 8,16,32 ...
    do 'NEXT MERGING PASS
      kk++      'TALLY ELEMENTS
      if kk>count
        exit do 'ALL ELEMENTS PROCESSED
      endif
      retest:
      if @ni>=bj
        if @nj>=ej 'MOVE TO NEXT GROUP PAIR
          bi+=stp
          bj+=stp
          ej+=stp
          @ni=bi
          @nj=bj
          'LIMIT EJ TO BOUNDARY ed
          if ej>ed
            ej=ed
          endif
          goto retest
        else '@nj<ej
          dj=nj
          @nj+=4
          'PICK FROM SECOND GROUP
        endif
      elseif @nj>=ej
        dj=ni
        @ni+=4
        'PICK FROM FIRST GROUP
      else 'ni<eej and nj<ed
        '
        'OTHERWISE COMPARE BEFORE PICKING
        sw=0
        compare sw, ni, nj 'COMPARE PROCEDURE
        if sw 
          dj=nj
          @nj+=4
        else
          dj=ni
          @ni+=4
        endif
      endif
      @dj+=4 'NEXT DESTINATION POSITION
    loop
    swap src,dest 'SWAP SOURCE/DESTINATION BASES FOR NEXT PASS
  loop
  }
reindex 20 reindex (idx,ct,cf,filt,comp,  i,f,x) {
  'idx            index name
  'ct             count of items
  'cf             resulting count of filtered items
  'filt  optional filter procedure for selecting items
  'comp  optional comparison procedure for sorting items
  '
  int *idx 'create the index file
  int cf   'filtered data counter
  cf=0
  if @idx
    freememory @idx 'clear counter
  endif
  @idx=getMemory 2*(ct)*sizeof int
  scope
    int x at @idx  'idx strider
    int i          'iterator
    int f          'filter flag
    for i=indexbase to ct+indexbase-1
      f=0
      #if def filt
        filt f,i
      #else
        f=1
      #endif
      if f
        x=i
        @x+=4
        cf++
      endif
    next
  end scope
  #if def comp
    _sort_ idx,cf,comp
  #endif
  }

'PSEUDO COMMANDS

asc_ 20 asc_(s,j, i,p,l,c){
  int i=j
  sys p=strptr s
  int l=len s
  if i<0
    i=l-i
  endif
  byte*c
  @c=&&c 'default sink
  if i>0
    if i<=l
      @c=p+i-1
    endif
  endif
  c
  }

unic_ 20 unic_(s,j, i,p,l,c){
  int i=j
  sys p=strptr s
  int l=len s
  if i<0
    i=l-i
  endif
  word*c
  @c=&&c 'default sink
  if i>0
    if i<=l
      @c=p+i*2-2
    endif
  endif
  c
  }

'==================================
'>>OXYGEN SYSTEM TERMINATION MACROS
'==================================

terminate 19 call [ebx+2448] : call [ebx+2144]
freestrings 19 call [ebx+2144]
freelibs 19 call [ebx+2448]

'===================
'LOW LEVEL FUNCTIONS
'===================

getmemory 4 8
freememory 4 16
loadlibrary 4 24
freelibrary 4 32
getprocaddress 4 40
getlasterror 4 88
setlasterror 4 96
copy0 4 56
copy00 4 64
copyn 4 72
copy 4 72
mbox 4 2048 'mboxa
comparestr 4 2192 ' comps ' COMPARING BSTRS




'=============================
'>>COMMON RESERVED WORDS
'=============================

exit   9 1
repeat 9 1
call   9 1
jmp    9 1
and    9 0
or     9 0
xor    9 0
not    9 1
null   9 1



'===========================
'>>O2 ATTRIBUTE MACROS
'===========================


sizeof      11 1  4
offsetof    11 2  4
countof     11 3  4
spanof      11 3  4
bytesof     11 4  4
typeof      11 5  193
structureof 11 6  193
encodingof  11 6  193
prototypeof 11 7  193
typecodeof  11 8  4
recordof    11 9  4
widthof     11 10 4
ptrlevelof  11 11 4
metatypeof  11 12 193
flagsof     11 13 4
strptr      11 21 8
lpartof     11 31 0
rpartof     11 32 0
vtypeof     11 33 0


'===========================
'>>O2 KEYWORDS
'===========================

incl 13 1
#semicolon 13 2
_neg 13 3
asm 13 6
with 13 7
expand 13 8
enum 13 9
o2 13 10
struct 13 11
bind 13 12
class 13 13
def 13 14
#def 13 14
deff 13 15
type 13 16
var 13 17
include 13 18
#include 13 18
packed 13 21
defx 13 22
namespace 13 23
restore 13 24
rem 13 26
includepath 13 30
librarypath 13 31
#file 13 34
quote 13 36
typedef 13 37
union 13 38
#fpnprecision 13 40
#case 13 41
#lookahead 13 43
#autodim 13 44
#alert 13 46
#error 13 47
#pragma 13 48
#unique 13 49
#console 13 50
#show 13 51 
addr 13 53 
#compact 13 54 
#cpointer 13 55 



'=================
'>>OXYGEN KEYWORDS
'=================

shared 14 1
let 14 2
dim 14 4
const 14 4
local 14 5
static 14 6
operator 14 7
! 14 8
declare 14 8
function 14 9
procedure 14 9
sub 14 10
method 14 11
loop 14 12 
if 14 13
then 14 14
else 14 15
elseif 14 16
endif 14 17
enddo 14 18
endwhile 14 19
endselect 14 20
endswitch 14 20
do 14 21
while 14 23
wend 14 24
exit 14 25
redo 14 26
continue 14 26
repeat 14 26
default 14 27
break  14 28
switch 14 29
select 14 29
case 14 30
for 14 31
to 14 32
step 14 33
next 14 34
endfor 14 34
goto 14 35
gosub 14 36
methods 14 37
return 14 38
% 14 39
$ 14 39
subroutine 14 40
script 14 41
scope 14 42
indexbase 14 44
export 14 46
lib 14 47
library 14 47
extern 14 48
that 14 49
this 14 50

#majorminor 14 51
#minormajor 14 52
#noprec 14 53
#noinit 14 54
#byval 14 55
#byref 14 56
#assign 14 58
#ending 14 60
'operations 14 63


'============
'METACOMMANDS
'============

#if 13 100
#else 13 101
#elseif 13 102
#endif 13 103
#define 13 104
#ifdef 13 105
#ifndef 13 106
undef 13 107
#undef 13 107
#undefine 13 107
alias 13 108 'thinBasic headers
macro 13 109
#print 13 110
'#ifexist 13 111
'#ifnexist 13 112
#eval 13 113
#macro 13 114

#blockdepth 13 201
#recordof 13 202
#list 13 203


'================================
'primitives (Basic and C style)
'================================


void      15 0x10 '* Used by-reference only
sbyte     15 0x01
byte      15 0x21
ubyte     15 0x21
string    15 0xe1
wstring   15 0xe2
bstring   15 0xc1
gstr_     15 0xc1 '* Accept any Bstring width. for core functions only
bstr      15 0xc1
wbstring  15 0xc2
char      15 0xa1
wchar     15 0xa2
cstr_     15 0xa1 '* Accept any char width. for core functions only
pstr_     15 0xb1 '* Accept any char width. for core functions (len returned in ecx)
asciiz    15 0xa1
zstring   15 0xa1
wzstring  15 0xa2
short     15 0x02
long      15 0x04
wide      15 0xa2
int       15 0x04
integer   15 0x04
float     15 0x64
single    15 0x64
double    15 0x68
extended  15 0x6A
quad      15 0x48 ''* using FPU on 32 bit systems (was 08), returns data on edx:eax
word      15 0x22
dword     15 0x24
ulong     15 0x24
uint      15 0x24
usys      15 0x28 '* 64 bit only
qword     15 0x58 '* using  FPU on 32 bit systems
any       15 0x08 '* to be used by reference only
sys       15 0x08 '* 4/8 depending on 32/64 bit system
bool      15 0x04 '* MS
boolean   15 0x01 '* MS
fpu       15 0x40 '* fast call using fpu registers (not exportable)
signed    15 0x04
unsigned  15 0x24



'===========================================
'>>OVERLOADABLE INTEGER AND STRING FUNCTIONS
' overloadable functions -16
' integer and string
' TREATED AS STDCALL
'===========================================



news  16 #sys@0 bstr 08
frees 16 #sys@0 sys 16
frees 16 #gstr_#@0 sys 16
error 16 #@ bstr 128
nuls  16 #sys@0 bstr 08
val   16 #zstring@1 fpu 192
valat 16 #sys@0 fpu 192
ltrim 16 #string@0 bstr 2312
rtrim 16 #string@0 bstr 2320
lcase 16 #string@0 bstr 2328
ucase 16 #string@0 bstr 2336
stringbytes 16 #sys#sys@00 bstr 2464
string 16 #sys#zstring@00 bstr 2472
string 16 #sys#string@00 bstr 2480
space 16 #sys@0 bstr 2488'
'left 16 #cstr_#sys@10 bstr 2400
'left 16 #gstr_#sys@00 bstr 2344
mid 16 #cstr_#sys@10 bstr 2424 
mid 16 #gstr_#sys@00 bstr 2416
mid 16 #cstr_#sys#sys@100 bstr 2392
mid 16 #gstr_#sys#sys@000 bstr 2360
mid_ 16 #cstr_#sys#gstr_@100 sys 2352 
mid_ 16 #gstr_#sys#gstr_@000 sys 2456
midstr 16 #cstr_#sys#sys@100 pstr_ 2272 
instr 16 #sys#string#string@000 sys 320
instr 16 #string#string@00 sys 2504
getfile 16 #cstr_#gstr_@11 sys 2512
getfile 16 #cstr_@1 bstr 336
putfile 16 #cstr_#gstr_@10 sys 344
print 16 #cstr_@1 sys 2496
asc 16 #string#sys@00 sys 2368
asc 16 #string@0 sys 2432
unic 16 #wstring#sys@00 sys 2528
unic 16 #wstring@0 sys 2536
len 16 #cstr_@1 sys 2408
len 16 #gstr_@0 sys 2376
chr 16 #sys@0 bstr 2384
wchr 16 #sys@0 wbstring 2544
str 16 #fpu#sys@00 bstr 200 
str 16 #fpu@0 bstr 2520
hex 16 #fpu@0 bstr 208 
hex 16 #fpu#sys@00 bstr 216
guidval 16  #guid#zstring@11 sys 352
guidval 16 #guid#bstr@10  sys 352
guidtxt 16 #guid@1 bstr 360
numberformat 16 #@ sys 2560 
numberformat 16 #sys#sys#sys#sys#sys#sys@000000 sys 2552


'===========================
'>>FLOATING POINT MACRO
' macro function
'===========================


abs 17 fabs
acos 17 fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fxch : fpatan
asin 17 fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fpatan
atan  17 fpatan
atn 17 fld1 : fpatan
cos 17 fcos
deg 17 fldpi : fdivp st1 : |sp -8 : mov [rsp],180 : fimul dword [rsp] : |sp 8
frac 17 fld1 : fxch : fprem : fstp st1
hypot 17 fmul st0 : fxch : fmul st0 : faddp st1 : fsqrt
lin 17 fldln2 : fxch : fyl2x
log 17 fldln2 : fxch : fyl2x
log2 17 fld1 : fxch : fyl2x
log10 17 fldlg2 : fxch : fyl2x
logn 17 fld1 : fxch st1 : fyl2x : fld1 : fdivrp st1 : fxch st1 : fyl2x
mod 17 fxch st1 : fprem : fstp st1
pi 17 fldpi

exp 17 
  |sp -16 : fstcw [rsp] : fstcw [rsp+2] : or [rsp],0xc00 : fldcw [rsp]
  fldl2e : fmulp st1 : fld st0 : frndint : fsub st1,st0
  fxch : f2xm1 : fld1 : faddp st1 : fscale : fstp st1
  fldcw [rsp+2] : |sp 16

pow 17 
  (
   fldz
   fucomip st2
   jnz exit
   fldz
   fucomip st1
   fstp st0
   fstp st0
   (
    jnz exit
    fld1
    jmp fwd _npower
   )
   fldz
   jmp fwd _npower
  )
  |sp -16 : fstcw [rsp] : fstcw [rsp+2] : or [rsp],0xc00 : fldcw [rsp] : ( :
  fist dword [rsp+8] : and byte [rsp+8],1 : jnz exit : fxch : fabs : fyl2x : fld st0
  frndint : fsub st1,st0 : fxch : f2xm1 : fld1 : faddp st1,st0 : fscale : fstp st1 : jmp fwd nng
  ) : fxch : fst dword [rsp+8] : fabs : fyl2x : fld st0 : frndint : fsub st1,st0 : fxch
  f2xm1 : fld1 : faddp st1,st0 : fscale : fstp st1 : ( : and byte [rsp+11],128 : jz exit : fchs : )
  .nng : fldcw [rsp+2] : |sp 16
  ._npower

rad 17 fldpi : fmulp st1 : |sp -8 : mov [rsp],180 : fidiv dword [rsp] : |sp 8
recip 17 fld1 : fdivrp
round 17 frndint

sgn 17 fldz : fcomip : ( :  jnz exit : fldz : jmp fwd _sd : )
       ( : ja exit : fld1 : jmp fwd _sd : ) : ( : jb exit : fld1 : fchs : jmp fwd _sd : )
      ._sd : fxch : fstp st0

sin 17 fsin
sqr 17 fsqrt
sqrt 17 fsqrt
tan 17 fptan : fstp st0

floor 17 |sp -8 : fstcw [rsp] : fstcw [rsp+4] : and word [rsp],0xf3ff : or word [rsp],0x400 : fldcw [rsp]
      frndint : fldcw [rsp+4] : |sp 8

ceil 17 |sp -8 : fstcw [rsp] : fstcw [rsp+4] : and word [rsp],0xf3ff : or word [rsp],0x800 : fldcw [rsp]
      frndint : fldcw [rsp+4] : |sp 8

trunc 17 |sp -8 : fstcw [rsp] : fstcw [rsp+4] : or word [rsp],0xc00 : fldcw [rsp]
      frndint : fldcw [rsp+4] : |sp 8


'===========================

 ,0,0 'mark end of data

~~~ 'closed quote


'===========================
'>>REGISTERS
'===========================

string x86_registers="

' regsize regno regtype

al    10 101
cl    10 111
dl    10 121
bl    10 131
ah    10 141
ch    10 151
dh    10 161
bh    10 171
'---------------------------
ax    10 201
cx    10 211
dx    10 221
bx    10 231
sp    10 241
bp    10 251
si    10 261
di    10 271
'---------------------------
eax   10 401
ecx   10 411
edx   10 421
ebx   10 431
esp   10 441
ebp   10 451
esi   10 461
edi   10 471
'---------------------------
st0   10 A02
st1   10 A12
st2   10 A22
st3   10 A32
st4   10 A42
st5   10 A52
st6   10 A62
st7   10 A72
'---------------------------
mmx0  10 F03 
mmx1  10 F13 
mmx2  10 F23 
mmx3  10 F33 
mmx4  10 F43 
mmx5  10 F53 
mmx6  10 F63 
mmx7  10 F73 
'---------------------------  
xmm0  10 F04
xmm1  10 F14
xmm2  10 F24
xmm3  10 F34
xmm4  10 F44
xmm5  10 F54
xmm6  10 F64
xmm7  10 F74
xmm8  10 F84
xmm9  10 F94
xmm10 10 FA4
xmm11 10 FB4
xmm12 10 FC4
xmm13 10 FD4
xmm14 10 FE4
xmm15 10 FF4
'---------------------------
cr0   10 405 '129  
cr2   10 415 
cr3   10 425 
cr4   10 435 
'---------------------------
dr0   10 406 '130  
dr1   10 416 
dr2   10 426 
dr3   10 436 
dr4   10 446
dr5   10 456 
dr6   10 466 
dr7   10 476 
'---------------------------
es    10 407'131  
cs    10 417 
ss    10 427 
ds    10 437 
fs    10 447
gs    10 457 
'---------------------------
'64 bit mode registers
'---------------------------
rax   10 809
rcx   10 819
rdx   10 829
rbx   10 839
rsp   10 849
rbp   10 859
rsi   10 869
rdi   10 879
r8    10 889
r9    10 899
r10   10 8A9
r11   10 8B9
r12   10 8C9
r13   10 8D9
r14   10 8E9
r15   10 8F9
'---------------------------
r8l   10 489
r9l   10 499
r10l  10 4A9
r11l  10 4B9
r12l  10 4C9
r13l  10 4D9
r14l  10 4E9
r15l  10 4F9
'---------------------------
r8w   10 289
r9w   10 299
r10w  10 2A9
r11w  10 2B9
r12w  10 2C9
r13w  10 2D9
r14w  10 2E9
r15w  10 2F9
'---------------------------
r8d   10 489
r9d   10 499
r10d  10 4A9
r11d  10 4B9
r12d  10 4C9
r13d  10 4D9
r14d  10 4E9
r15d  10 4F9
"

'end of data x86 registers






'===
'END
'===



