Author Topic: MasmBasic  (Read 293428 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10677
  • 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: 10677
  • 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: 10677
  • 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).