News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MasmBasic

Started by jj2007, October 06, 2009, 08:24:57 PM

Previous topic - Next topic

Dharam

I still am not sure whether this file masmbasic.inc is availble for general testing or not.  It it is available, where is it?

ecube

I wish to the source of masmbasic, THANKS  :thumbu

jj2007

Quote from: Dharam on September 26, 2010, 10:28:03 PM
I still am not sure whether this file masmbasic.inc is availble for general testing or not.  It it is available, where is it?

In the first post of this thread, a zip file is attached. Open it, and double-click on ReadMeMasmBasic.txt

jj2007

Quote from: E^cube on September 27, 2010, 01:51:18 AM
I wish to [see] the source of masmbasic, THANKS  :thumbu

Cube,

MB as such is not open source, sorry. However,
- MasmBasic.inc is visible - and there are all the macros
- if you are really curious, insert int 3 into the macro you want to investigate, and Olly will show you the way.

In case MB does not behave as a proper BASIC should, post your code here, and we'll investigate the bug if there is one (I currently know of one, but it's fairly exotic: Dim Something As BYTE will not work together with Print Str$(Something(123)).

jj2007

#154
Update with three new functions: PopCount(), Percent(), Rand()
Note this is a beta, not thoroughly tested.

QuotePopCount
[/color]   PopCount(MySource, ecx)            ; standalone: set count to ecx
   mov ebx, 88888888h
   Print Str$("In ebx, %i bits are set", PopCount(ebx))   ; for use with Str$() etc
   void PopCount(ebx)               ; returns bitcount in eax
   mov MyVar, PopCount(MySource)
Rem   [/color]runs in about 7 cycles on a Celeron M; requires Init or at least one Str$(0) before


Percent, [/color]f4Percent, f8Percent, fpuPercent
[/color]            Print Str$("f4pc(srcr10, 33.33)=\t%If\n", f4Percent(srcr10, 33.33))   ; f4: returns REAL4
            Print Str$("f8pc(srcr10, 33.33)=\t%If\n", f8Percent(srcr10, 33.33))   ; f8: returns REAL8 e.g. for use with xmm regs
            Print Str$("fpupc(srcr10, pcr10)=\t%If\n", fpuPercent(srcr10, pcr10))   ; fpu: leaves result in ST(0)
            Print Str$("fpc(12345.678, ebx)=%f\n", f8Percent(12345.678, ebx))
            Print Str$("fpc(12345.6, ebx)=%f\n", f8Percent(12345.6, ebx))
            Print Str$("pc(12345.0, ebx)=%f\n", Percent(12345.0, ebx))      ; with immediate real source and reg32 percentage
            Print Str$("pc(srcdd, ebx)=%f\n", Percent(srcdd, ebx))         ; with DWORD source and reg32 percentage
            Print Str$("pc(12345, 20)=%f\n", Percent(12345, 20))         ; with immediate integer source and percentage
            movq xmm0, f8Percent(srcr10, 33.33)
            Print Str$("xmm0=%f\n", f:xmm0)
            movd xmm0, Percent(srcr10, 33.33)
            Print Str$("xmm0=%f\n", xmm0)
Rem   source can be almost anything, same for percentage


Rand
            Rand()                     [/color]; empty args = initialise using rdtsc
            
Rand(0, 100, xmm1)      ; 0....+100, dest can be local/global REAL8 var or xmm
            Rand(0, ebx, MyReal8)   ; 0....ebx, dest can be local/global REAL8 var or xmm
            Rand(0, 100)               ; 0....+100, left on FPU in st(0)
            
Rand(-5.5, 9.3)            ; -5.3...+9.3, left on FPU in st(0)
            
Print Str$("-5.5, 9.3: ST(0)=\t%If\n", ST(0))
            void Rand(123)            ; leaves dword in eax
            mov ecx, Rand(123)      ; range 0...123
            mov ecx, Rand(MyDword)   ; range passed as dword variable
Rem   [/color]- high-speed RNG generates pseudo random sequence with excellent randomness
   - for testing, do not initialise; for release version, use Rand() before the innermost loop
   - credits to Alex Bagayev for his AxRand algo

EDIT: Attachment removed, valid version is attached to top of thread, page 1

Antariy

Jochen, is PopCount with lookup table?

Edited: Yes, I see - it is.

jj2007

Yes, generated on the fly during Init.

jj2007

Quote from: Antariy on November 12, 2010, 10:19:40 PM
Jochen which count of downloads have your archive from post above? Something interesting - I see 0, but I have downloaded it.

Alex, I have updated the archive with your correct name spelling in the MbGuide.rtf help file. That is why you see 0 downloads - it is a new archive. Note the tiny difference in the filename.

Antariy

Quote from: jj2007 on November 12, 2010, 10:29:03 PM
Alex, I have updated the archive with your correct name spelling in the MbGuide.rtf help file. That is why you see 0 downloads - it is a new archive. Note the tiny difference in the filename.

Maybe that is reason. Some days ago - at time when I click on the link at Frank's tesd-bed thread, he are remove archive from post at the same time - and browser thread was freezed - very funny  :green2

jj2007

Alex pointed me to an omission in the documentation of Rand(): the higher end of the range is not included.

esi=-100, ebx=100; run 1=lowest, run 2=highest value
0, 100:    xmm1=        0.0
0, ebx:    xmm1=        0.0
esi, 0:    xmm1=        -100.000000000000000
esi, ebx:  xmm1=        -100.000000000000000
0, 100:    ST(0)=       0.0
-5, 9:     ST(0)=       -5.00000000000000000
-5.5, 9.3: ST(0)=       -5.50000000000000000
0, 1:      destR8=      0.0
0, -1:     destR8=      0.0
mov ecx, Rand(123):     0.0

0, 100:    xmm1=        99.9999999767170777
0, ebx:    xmm1=        99.9999999767170777
esi, 0:    xmm1=        -2.32829089411024093e-08
esi, ebx:  xmm1=        99.9999999534341697
0, 100:    ST(0)=       99.9999999767170911
-5, 9:     ST(0)=       8.99999999674039275
-5.5, 9.3: ST(0)=       9.29999999655413019
0, 1:      destR8=      0.999999999767170800
0, -1:     destR8=      -0.999999999767170911
mov ecx, Rand(123):     122.000000000000000


Generated by:
  Rand(0, 100, xmm1) ; 0...100 (exclusive), dest can be local/global REAL8 var or xmm
  Print Str$("0, 100:    xmm1=\t%If\n", f:xmm1)
  Rand(0, ebx, xmm1) ; 0...100 (exclusive), dest can be local/global REAL8 var or xmm
  Print Str$("0, ebx:    xmm1=\t%If\n", f:xmm1)
  Rand(esi, 0, xmm1) ; 0...100 (exclusive), dest can be local/global REAL8 var or xmm
  Print Str$("esi, 0:    xmm1=\t%If\n", f:xmm1)
  Rand(esi, ebx, xmm1) ; 0...100 (exclusive), dest can be local/global REAL8 var or xmm
  Print Str$("esi, ebx:  xmm1=\t%If\n", f:xmm1)
  Rand(0, 100) ; 0...100 (exclusive), left on FPU in st(0)
  Print Str$("0, 100:    ST(0)=\t%If\n", ST(0))
  fstp st ; correct FPU stack
  Rand(-5, 9) ; -5...+9, left on FPU in st(0)
  Print Str$("-5, 9:     ST(0)=\t%If\n", ST(0))
  fstp st ; correct FPU stack
  Rand(-5.5, 9.3) ; -5.3...+9.3, left on FPU in st(0)
  Print Str$("-5.5, 9.3: ST(0)=\t%If\n", ST(0))
  fstp st ; correct FPU stack
  Rand(0, 1, destR8) ; 0...1 (exclusive), dest can be local/global REAL8 var or xmm
  Print Str$("0, 1:      destR8=\t%If\n", destR8)
  Rand(0, -1, destR8) ; -1...0, dest can be local/global REAL8 var or xmm
  Print Str$("0, -1:     destR8=\t%If\n", destR8)
  void Rand(123) ; leaves dword in eax
  mov ecx, Rand(123) ; range 0...123
  Print Str$("mov ecx, Rand(123): \t%If\n\n", ecx)

hutch--

I still want a copy of the "Espresso Machine" code when it becomes available.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

yah, Jochen - that Rand function isn't washing our dishes over here   :bg

Z sends a K

jj2007

Quote from: hutch-- on November 14, 2010, 01:16:04 AM
I still want a copy of the "Espresso Machine" code when it becomes available.  :bg

Hutch,
Please send the documentation of the interface. USB port, or is it one of those stone age machines that are addressed through the serial port?
:wink

Quote from: dedndave on November 14, 2010, 02:57:41 AM
yah, Jochen - that Rand function isn't washing our dishes over here   :bg

Dave,
If it was, it would be the World's fastest dish washer, of course - the macro version of AxRand runs in 13 cycles, and is 21 bytes short.

But the implementation would be a bit, ehm, challenging. My advice: Take a big hammer. After 13 minutes of hard work, your china will look sufficiently random :bg

Quote
Z sends a K
J sends 2 K :red  (to Z, not to you, of course)

hutch--

JJ,

I was hoping for SATA 6.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on November 14, 2010, 08:53:33 AM
JJ,
I was hoping for SATA 6.

Hutch,
When I watch the barmen preparing coffee here in Italy, yes they are definitely very fast, but 6 Gbits/s...????
::)