Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /mathlib/src/

mathlib
Discussion topic

Back to topic list

CVS update: /mathlib/src/

Reply

Author larin
Full name Serge Larin
Date 2004-04-19 08:28:53 PDT
Message User: larin
Date: 04/04/19 08:28:53

Added:
 /mathlib/src/
  exchange.asm, move.asm, mrng.asm, normal.asm, rayleigh.asm, uniform.asm

Log:
 First public release on mathlib.tigris.org

File Changes:

Directory: /mathlib/src/
========================

File [added]: exchange.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/exchange​.asm?rev=1.1&con​tent-type=text/vnd.v​iewcvs-markup
Added lines: 67
---------------
; EXCHANGE.ASM

; Base on EXCHANGE.ASM from the Turbo Assembler Users Guide
; Copyright (c) 1988, 1991 By Borland International, Inc.

; Version 1.00.00

; Portions copyright (c) 1998 By Larin S.L.

; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;

ideal
p386
model large,PASCAL

codeseg
public ExchangeVal

; procedure ExchangeVal(Var Var1,Var2;count:word);
; Ž¡¬¥­ §­ ç¥­¨© ¤¢ãå ¯¥à¥¬¥­­ëå

proc ExchangeVal FAR var1:DWORD,var2:DWOR​D,count:WORD
          cld ;
          push ds ;á®åà ­¨âì DS
          lds si,[var1] ;§ £à㧨âì ¢ DS:SI  ¤à¥á var1
          les di,[var2] ;§ £à㧨âì ¢ ES:DI  ¤à¥á var2
          xor ecx,ecx
          mov cx,[count] ;§ £à㧨âì ¢ CX count
          jcxz @@Finish ;¥á«¨ count=0, ­  ¢ë室
          shr cx,1 ;¬« ¤è¨© ¡¨â áç¥â稪  -> CF
          jnc short ExchangeWords ;¯¥à¥å®¤, ¥á«¨ ç¥â­®¥
          mov al,[es:di] ;ç⥭¨¥ ­¥ç¥â­®£® ¡ ©â  var2
          movsb ;¯¥à¥­®á ¡ ©â  ¨§ var1 ¢ var2
          mov [si-1],al ;§ ¯¨áì ¡ ©â  var2 ¢ var1
          jz short @@Finish ;¢ë室, ¥á«¨ count=1
ExchangeWords:
          shr cx,1 ;¬« ¤è¨© ¡¨â áç¥â稪  -> CF
          jnc short ExchangeLongint ;¯¥à¥å®¤, ¥á«¨ ç¥â­®¥
          mov ax,[es:di] ;ç⥭¨¥ ­¥ç¥â­®£® á«®¢  var2
          movsw ;¯¥à¥­®á á«®¢  ¨§ var1 ¢ var2
          mov [si-2],ax ;§ ¯¨áì á«®¢  var2 ¢ var1
          jz short @@Finish ;¢ë室, ¥á«¨ ¢á¥ ¯¥à¥­¥á¥­®
ExchangeLongint:
          mov bx,-4 ;
ExchangeLoop:
          mov eax,[es:di] ;ç⥭¨¥ ¤¢®©­®£® á«®¢  var2
          movsd ;¯¥à¥­®á ¤¢®©­®£® á«®¢  ¨§ var1 ¢ var2
          mov [bx+si],eax ;§ ¯¨áì ¤¢®©­®£® á«®¢  var2 ¢ var1
          loop short ExchangeLoop ;
@@Finish:
          pop ds ;¢®ááâ ­®¢¨âì DS
          ret
endp
end

File [added]: move.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/move.asm​?rev=1.1&content​-type=text/vnd.viewc​vs-markup
Added lines: 54
---------------
; Version 1.00.00

; Copyright (c) 1998 By Larin S.L.

; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;

ideal
p386
model large,PASCAL

codeseg
public Move

; procedure Move(var Source,Dest;count:word);
; Copies bytes from source to dest.

proc Move FAR Source:DWORD,Dest:DW​ORD,count:WORD
          cld ;
          push ds ;á®åà ­¨âì DS
          lds si,[Source] ;§ £à㧨âì ¢ DS:SI  ¤à¥á Source
          les di,[Dest] ;§ £à㧨âì ¢ ES:DI  ¤à¥á Dest
          xor ecx,ecx
          mov cx,[count] ;§ £à㧨âì ¢ CX count
          jcxz @@Finish ;¥á«¨ count=0, ­  ¢ë室
          shr cx,1 ;¬« ¤è¨© ¡¨â áç¥â稪  -> CF
          jnc short @@MoveWords;¯¥à¥å®¤, ¥á«¨ ç¥â­®¥
          movsb ;¯¥à¥­®á ¡ ©â  ¨§ Source ¢ Desin
          jz short @@Finish ;¢ë室, ¥á«¨ count=1
@@MoveWords:
          shr cx,1 ;¬« ¤è¨© ¡¨â áç¥â稪  -> CF
          jnc short @@MoveLongint ;¯¥à¥å®¤, ¥á«¨ ç¥â­®¥
          movsw ;¯¥à¥­®á á«®¢  ¨§ Source ¢ Dest
          jz short @@Finish ;¢ë室, ¥á«¨ ¢á¥ ¯¥à¥­¥á¥­®
@@MoveLongint:
          rep movsd ;¯¥à¥­®á ¤¢®©­ë¬¨ á«®¢ ¬¨ ¨§ Source ¢ Dest
@@Finish:
          pop ds ;¢®ááâ ­®¢¨âì DS
          ret
endp

end

File [added]: mrng.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/mrng.asm​?rev=1.1&content​-type=text/vnd.viewc​vs-markup
Added lines: 131
----------------
;
; The "Mother-of-all Pseudo Random Number Generators"
; Invented by Dr. George Marsaglia, Florida St. Univ., Dept. of Statistics
; Assembly implementation by Agner Fog
; Delphi BASM conversion, v1.0, (c)1999, EFD Systems
; Free Pascal and Borland Pascal conversion, v1.0, (c) 2001, Larin S.L.
;
; Excellent statistical properties and extremely long
; cycle length (approx. 3*10^47)

; You may also want to grab the free MRNG.PAS from EFD Systems:
; EFD: http://efd.home.mind​spring.com/tools.htm​
;

; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;


ideal
p386
model large, pascal

SizeOffloat equ tbyte ptr; à §¬¥à ¢¥é¥á⢥­­®£® ⨯  (extended)

dataseg

  ; Š®­áâ ­âë

  extrn MC :dword
  extrn M3 :dword
  extrn M2 :dword
  extrn M1 :dword
  extrn M0 :dword
  extrn MF3 :dword
  extrn MF2 :dword
  extrn MF1 :dword
  extrn MF0 :dword
  extrn F2M32 :dword
  extrn EXTEND:qword

ends

codeseg

public MRandom, MRandSeed

; function MRandom:float;assembler;
; Generate random decimal in the range [0..1]

proc MRandom far
   push edi
   mov eax, [dword ptr MF3]
   mul [dword ptr M3]
   mov ecx,eax
   mov eax, [dword ptr M2]
   mov edi,edx
   mov [dword ptr M3], eax
   mul [dword ptr MF2]
   add ecx,eax
   mov eax, [dword ptr M1]
   adc edi,edx
   mov [dword ptr M2],eax
   mul [dword ptr MF1]
   add ecx,eax
   mov eax,[dword ptr m0]
   adc edi,edx
   mov [dword ptr M1],eax
   mul [dword ptr MF0]
   add eax,ecx
   adc edx,edi
   add eax,[dword ptr MC]
   adc edx,0
   mov [dword ptr M0],eax
   mov [dword ptr MC],edx
   mov di, offset EXTEND
   mov [dword ptr di],eax
   fild [qword ptr EXTEND]
   pop edi
   fmul [dword ptr F2M32]
   ret
endp

; procedure MRandSeed(Seed:longi​nt);assembler;
; Initialize generator; use Seed := GetTickCount to initialize
; from system clock

proc MRandSeed FAR Seed:DWORD
  push edi
  mov eax, [Seed]
  cmp eax, 1
  sbb eax, 0
  mov ecx, 5
  mov bx, offset M0
@R80:
  mov edx, eax
  shl eax, 13
  xor edx, eax
  mov eax, edx
  shr edx, 17
  xor eax, edx
  mov edx, eax
  shl edx, 5
  xor eax, edx
  mov [dword ds:bx], eax
  sub bx, 4
  loop @R80
  mov edi, 19
@R90:
  push cs
  call near MRandom
  fstp st(0)
  dec edi
  jnz @R90
  pop edi
  ret
endp

ends
end

File [added]: normal.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/normal.a​sm?rev=1.1&conte​nt-type=text/vnd.vie​wcvs-markup
Added lines: 107
----------------
;
; Normal distribution randomize generator
;
; Version 1.00.00
; Copyright (c) 1998,2000 by Larin S.L.
;
; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;


ideal
p386
model large, pascal

SizeOffloat equ tbyte ptr; à §¬¥à ¢¥é¥á⢥­­®£® ⨯  (extended)

dataseg

  ;
  extrn tInit1:dword
  extrn tInit2:dword
  extrn tr1:tbyte
  extrn t_ret_r1:byte

  ; Š®­áâ ­âë

  extrn const_1:dword
  extrn const_2:dword
  extrn const_3:dword
  extrn const_4:dword

ends

codeseg

public tNormal

; function tNormal:float;
; ƒ¥­¥à â®à á«ãç ©­ëå ç¨á¥« á ­®à¬ «ì­ë¬ à á¯à¥¤¥«¥­¨¥¬

proc tNormal far

; ®à¬ «ì­®¥ à á¯à¥¤¥«¥­¨¥

; tInit2 := 2045*tInit2+1;
; tInit2 := tInit2-trunc(tInit2/​1048576)*1048576;
; Rndm1 := (tInit2+1)/1048577.0;

; tInit2 := 2045*tInit2+1;
; tInit2 := tInit2-trunc(tInit2/​1048576)*1048576;
; Rndm2 := 2*pi*(tInit2+1)/1048577.0;
; r0 := sqrt(-2.*ln(Rndm1))*cos(Rndm2);
; r1 := sqrt(-2.*ln(Rndm1))*sin(Rndm2);
   cmp [t_ret_r1],0
   jz @@1
   fld [tr1]
   dec [t_ret_r1]
   ret
@@1:
   imul eax,[dword ptr tInit2],2045
   inc eax
   div [dword ptr const_1]
   mov [dword ptr tInit2],edx
   inc [dword ptr tInit2]

   fldln2
   fild [dword ptr tInit2]
   fidiv [dword ptr const_2]
   dec [dword ptr tInit2]
   fyl2x
   fimul [dword ptr const_3]
   fsqrt

   imul eax,[dword ptr tInit2], 2045
   inc eax
   div [dword ptr const_1]
   mov [dword ptr tInit2],edx
   inc [dword ptr tInit2]
   fild [dword ptr tInit2]
   fidiv [dword ptr const_2]
   dec [dword ptr tInit2]
   fild [dword ptr const_4]
   fmulp st(1),st
   fldpi
   fmulp st(1),st

   fsincos
   fmul st,st(2)
   fstp [tr1]
   fmulp st(1)
   inc [t_ret_r1]
   ret
endp
ends
end

File [added]: rayleigh.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/rayleigh​.asm?rev=1.1&con​tent-type=text/vnd.v​iewcvs-markup
Added lines: 74
---------------
;
; Rayleigh distribution randomize generator
;
; Version 1.00.00
; Copyright (c) 1998,2000 by Larin S.L.
;
; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;


ideal
p386
model large, pascal

SizeOffloat equ tbyte ptr; à §¬¥à ¢¥é¥á⢥­­®£® ⨯  (extended)

dataseg

  ;
  extrn tInit1:dword
  extrn tInit2:dword

  ; Š®­áâ ­âë

  extrn const_1:dword
  extrn const_2:dword
  extrn const_3:dword
  extrn const_4:dword

ends

codeseg

public tRayleigh

; function tRayleigh:float;
; Rayleigh

proc tRayleigh far

; tInit1 := 2045*tInit1+1;
; Init1 := tInit1-trunc(tInit1/​1048576)*1048576;
; Rndm := (tInit1+1)/1048577;
; Reley := sqrt(-2*ln(Rndm));

   imul eax, [dword ptr tInit1], 2045 ; edx:eax = 2045*tInit1
   inc eax ;
   div [dword ptr const_1] ; edx := tInit1-trunc(tInit1/​1048576)*1048576
   mov [dword ptr tInit1],edx ;
   inc [dword ptr tInit1] ;
   fldln2 ; ‡ £à㧪  ln(2)
   fild [dword ptr tInit1] ; ‡ £à㧪  (tInit+1)
   fidiv [dword ptr const_2] ; st(0) := (tInit1+1)/1048577
   dec [dword ptr tInit1] ;
   fyl2x ; st(0) := st(1)*log2(st(0))
   fimul [dword ptr const_3] ; st(0) := -2*st(0)
   fsqrt ; st(0) := sqrt(st(0))
   ret
endp

ends
end

File [added]: uniform.asm
Url: http://mathlib.tigri​s.org/source/browse/​mathlib/src/uniform.​asm?rev=1.1&cont​ent-type=text/vnd.vi​ewcvs-markup
Added lines: 69
---------------
;
; Uniform distribution randomize generator
;
; Version 1.00.00
; Copyright (c) 1998,2000 by Larin S.L.
;
; The Pascal library is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; The Pascal library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;


ideal
p386
model large, pascal

SizeOffloat equ tbyte ptr; à §¬¥à ¢¥é¥á⢥­­®£® ⨯  (extended)

dataseg

  ;
  extrn tInit1:dword
  extrn tInit2:dword

  ; Š®­áâ ­âë

  extrn const_1:dword
  extrn const_2:dword
  extrn const_3:dword
  extrn const_4:dword

ends

codeseg

public tUniform

; function tUniform:float;

proc tUniform far

; ƒ¥­¥à â®à á«ãç ©­ëå ç¨á¥« á à ¢­®¬¥à­ë¬ à á¯à¥¤¥«¥­¨¥¬

; tInit1 := 2045*tInit1+1;
; tInit1 := tInit1-trunc(tInit1/​1048576)*1048576;
; Result := (tInit1+1)/1048577;

   imul eax, [dword ptr tInit1], 2045 ; edx:eax = 2045*tInit1
   inc eax ;
   div [dword ptr const_1] ; edx := tInit1-trunc(tInit1/​1048576)*1048576
   mov [dword ptr tInit1],edx ;
   inc [dword ptr tInit1] ;
   fild [dword ptr tInit1] ; ‡ £à㧪  (tInit+1)
   fidiv [dword ptr const_2] ; st(0) := (tInit1+1)/1048577
   dec [dword ptr tInit1] ;
   ret
endp
ends
end




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@math​lib.tigris.org
For additional commands, e-mail: cvs-help at mathlib dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /mathlib/src/ larin Serge Larin 2004-04-19 08:28:53 PDT
Messages per page: