Author Topic: MasmBasic  (Read 310644 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
StringBuild macro for fast concatenation of strings in the MegaByte range
« Reply #525 on: October 16, 2020, 01:03:57 PM »
Update 16 October 2020 is online and features a new StringBuild macro:

Code: [Select]
StringBuild edi ; ---------- start building the string
For_ ecx=1 To 70000
Let edi=CrLf$+"string "+Str$("#%i", ecx)
Next
StringBuild ; ---------- stop string building

For a 1MB string, the speed gain compared to Let my$=my$+"xx" is roughly a factor 1,000 :cool:

With e.g. StringBuild some$, 2000000 the default 1MB allocation can be adjusted if needed. For usedeb=1 (default), overflow will trigger a MsgBox; this costs a few bytes more but has practically no influence on performance.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Linear regression
« Reply #526 on: October 25, 2020, 12:18:42 PM »
GuiParas equ "Plotting a linear regression", w600, h300, col Pink, icon Plot, b RgbCol(0, 0, 0)
include \masm32\MasmBasic\Res\MbGui.asm
  ArrayRead x() As REAL8, 90    ; get x+y arrays
  ArrayRead y() As REAL8, 91    ; from resources
  Dim y2() As REAL8             ; this array will hold the regression line
  GetLinReg x(), y()            ; set the A and B coefficients
  For_ ecx=0 To eax-1           ; #elements in eax
        SetFloat <y2(ecx)>=LinRegY(x(ecx))      ; <destination> brackets needed here
  Next
Event Paint
  ArraySet MyRange() As REAL4=-0.5, 0.0, 3.2, 50.0
  ArrayPlot MyRange(XY), setrange
  ArrayPlot x():y(), RgbCol(255, 255, 255, 0), 5
  ArrayPlot x():y2(), RgbCol(160, 255, 0, 0), lines=3
  ArrayPlot exit, "Linear regression"
EndOfCode
Rsrc
90 RCDATA       "RegressionX.dat"
91 RCDATA       "RegressionY.dat"
Rsrc


Source, exe and data files attached - building requires MasmBasic version 25 October 2020

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #527 on: October 27, 2020, 11:57:15 AM »
Version 27.10.2020:
- bugfix: ArrayStripDuplicates could set a faulty last value
- new: ArrayMinMax myarray(), minVar, maxVar (i.e. you can now specify two destination variables)
- new: AddFloat, e.g. SetFloat myRealX=123.456, AddFloat myRealX=[any immediate number or numeric variable]
- ArraySet accepts now variables, e.g. ArraySet xyarray() As REAL4=maxDate, 0.0, minDate, ecx

Finally, RichMasm's layout improved slightly: the pinboard has moved to the upper right corner, as shown below (this is the proc called by GuiImage - a bit over 350 lines).


xandaz

  • Member
  • ***
  • Posts: 368
  • I luv you babe
    • My asm examples
Re: MasmBasic
« Reply #528 on: November 02, 2020, 02:32:02 AM »
  MasmBasic gives net error when downloading. can someone give me a valid linlk?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #529 on: November 02, 2020, 02:32:58 AM »
http://masm32.com/board/index.php?topic=94.0 doesn't work for you? I just tested it, everything works as it should...

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
The Russian Guitars
« Reply #530 on: November 04, 2020, 03:58:48 AM »
I found lovely music that doesn't distract me from coding: The Russian Guitars 1800-1850

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8127
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MasmBasic
« Reply #531 on: November 14, 2020, 07:13:01 PM »
Nice track, like it.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

2B||!2B

  • Member
  • **
  • Posts: 80
Re: MasmBasic
« Reply #532 on: December 07, 2020, 05:45:16 PM »
jj,

The new update seems to give errors about unresolved externals. Why?
Code: [Select]
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _CreateFontIndirectA@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _GetOpenFileNameA@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _GetOpenFileNameW@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _GetSaveFileNameA@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _GetSaveFileNameW@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _SHBrowseForFolderA@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _SHGetPathFromIDListA@8 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _CoTaskMemFree@4 referenced in function _MbCloseN@0
MasmBasic.lib(LibTmpAB.obj) : error LNK2019: unresolved external symbol _StdOut@4 referenced in function _TestRetVal@0

Also, how can i redim an array that has been allocated by Dim?

Example:
Code: [Select]
Dim My$(999) As DWORD
Dim My$(new:1234)

Errors
Code: [Select]
Error A2102: Symbol not defined : newThe documentation is so confusing.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #533 on: December 07, 2020, 09:13:11 PM »
The new update seems to give errors about unresolved externals. Why?

I've just downloaded the installer, and used it on a "virgin" Masm32 installation. Everything works fine... did you modify any Masm32 files? Does it work now, if yes: what did you change? I am curious what could be the cause, as I cannot reproduce this problem.

Quote
Also, how can i redim an array that has been allocated by Dim?

Example:
Code: [Select]
Dim My$(999) As DWORD
Dim My$(new:1234)

Errors
Code: [Select]
Error A2102: Symbol not defined : new

When you add As DWORD, MasmBasic assumes you want a numeric array. I will add an error message to catch this :cool:

Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
  Init
  Dim MyDouble() As REAL8 ; a numeric array
  Dim My$() ; a string array
  For_ ecx=0 To 9
Let My$(ecx)=Str$("This is string #%i", ecx) ; assign strings
  Next
  For_ ecx=0 To 9
PrintLine "[", My$(ecx), "]" ; display them
  Next
  Dim My$(new:99)
  Print Str$("The new array has %i elements\n", My$(?))
  For_ ecx=0 To 9
PrintLine "[", My$(ecx), "]" ; empty strings
  Next
EndOfCode

Quote
The documentation is so confusing.

Sorry for that... I'm not very good at writing help files, I know. Just ask if you run into a problem.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #534 on: December 10, 2020, 12:26:39 PM »
The new update seems to give errors about unresolved externals. Why?
Code: [Select]
MasmBasic.lib(LibTmpAC.obj) : error LNK2019: unresolved external symbol _CreateFontIndirectA@4 referenced in function _MbCloseN@0 ...

Does anybody else have such problems? I can't reproduce it here...

Today's update simplifies the re-dimensioning of string arrays:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc ; download
  Init
  Dim My$() ; create a string array
  For_ ecx=0 To 99
Let My$(ecx)=Str$("String #%i", ecx)
  Next
  Print Str$("This array has %i elements\n", My$(?))
  Dim My$() ; re-dim it
  For_ ecx=0 To 9
Let My$(ecx)=Str$("New string #%i", ecx)
  Next
  Inkey Str$("The new one has %i elements\n", My$(?))
EndOfCode

Output:
Code: [Select]
This array has 100 elements
The new one has 10 elements

Attached the demo, but with code for a two-dimensional string array

2B||!2B

  • Member
  • **
  • Posts: 80
Re: MasmBasic
« Reply #535 on: December 15, 2020, 03:45:43 PM »
Hi JJ,

Sorry for the late reply. Yes, i modded some masm32 inc files to remove the duplicate of include of files.
I think that is the cause of this issue. But previous version(not sure which one i currently use as i have no idea how to get the version) is working.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 11145
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #536 on: December 15, 2020, 08:33:46 PM »
Hi JJ,

Sorry for the late reply. Yes, i modded some masm32 inc files to remove the duplicate of include of files.
I think that is the cause of this issue. But previous version(not sure which one i currently use as i have no idea how to get the version) is working.

That is generally not a good idea, as you are no longer compatible with anybody else in the forum. And to my knowledge, duplicates of include files were never an issue, neither for MasmBasic nor for plain Masm32 SDK code (it shows in the output window if there are any duplicates).

As to the version: all files have a date+time stamp.