News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic

Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic

jj2007

Quote from: azdps on October 15, 2015, 01:52:02 AMI was attempting to install your masmbasic library but the install screen is too large for my laptop screen.

Thanks a lot for your feedback, azdps. The installer should be OK with version 16 October.

Quote- The ReadMeMasmBasic.txt shows the download location for JWasm at "http://www.japheth.de/JWasm.html#jwdownload" which seems to be an invalid location now.

- After replacing ml.exe with Jwasm.exe I received an error

That ReadMe is obsolete and will disappear soon. Re JWasm, just hit F6 when you see the manual, RichMasm will install JWasm. If Avast allows it, of course :bgrin:

And indeed, JWasm is occasionally a bit stricter than ML, but that's a feature IMHO. You may try also Nidud's AsmC, it's incredibly fast and seems to work fine now.

Version 16 October 2015: Fixed a few minor glitches in RichMasm, and re-installed the possibility to concatenate FileRead$() as in the snippet below.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  StringToArray FileRead$("\Masm32\include\Windows.inc")+FileRead$("http://masm32.com/board/index.php?action=help")+FileRead$("\Masm32\include\WinExtra.inc"), x$()
  push eax
  For_ ecx=0 To eax-1
      .if Instr_(x$(ecx), "<head>", 1)
            PrintLine "...", CrLf$, Str$(ecx), Tb$, "[", Left$(x$(ecx), 70), " ...]"      ; print one line of the embedded HTML code
      .endif
      mov edx, stack
      sub edx, 4
      .if ecx<5 || ecx>=edx      ; print first 5 and last 4 strings
            .if Zero?
                  PrintLine "..."
            .endif
            PrintLine Str$(ecx), Tb$, x$(ecx)
      .endif
  Next

  pop edx
  pop edx
  Store "ThreeFiles.txt", x$()      ; write all strings to disk
  ShEx "ThreeFiles.txt"      ; show the result in Notepad
EndOfCode

bsdsource

jj2007 when testing the newest installer from the SetupMasmBasic17Oct15.zip the buttons now show at the bottom so it will install now. Just for testing purposes I pressed on the Masm32 Forum button and the program crashes and an error message box displays indicating the following: Setup.exe has stopped working. A problem caused the program to stop working correctly. Please close the program. I get the crash as well when clicking on close at the top right corner. The install button works without any issues.

I'm using Windows 8.1 32bit. Haven't tested it on my desktop which is running Windows 7 yet.

jj2007

#287
Thanks, azdps, for this information. It is indeed a bug, and I am trying to fix it right now.

EDIT: Fixed in version 19 October, please download and reinstall.

Extract$() has now a wildcard option:
Let t$(ct, subject)=Extract$(esi, Chr$('class="subject"*"', 62), '</a>', xsWildcard)

Useful if you want to extract e.g. The Campus from
<a class="subject" href="http://masm32.com/board/index.php?board=1.0" name="b1">The Campus</a>

With the attached example, this output can be obtained:
The Campus                  Today at 07:48:01 AM             Re: Calling an EXEs export functions
The Workshop                Today at 07:56:53 AM             Re: MasmBasic
The Laboratory              Today at 07:02:35 AM             Re: GetCpuFrequency Tests
The Soap Box                Today at 11:45:25 AM             Re: What base jumpers do when they grow up. :)
The Colosseum               Today at 11:50:13 AM             Re: Microsoft 'Accident' Forces Windows 10 Onto Windows 7, Windows

jj2007

Please reinstall MasmBasic (safe, doesn't overwrite any user sources). This bug affects all versions before today:

include \masm32\MasmBasic\MasmBasic.inc      ; download the good version
  Init
  Let edi="LMR"
  Let esi=Mid$(edi, 2, 1)+Str$(0)+Mid$(edi, 2, 1)      ; M0M, OK
  PrintLine "[", esi, "]"      ; Mid$+Str$+Mid$ ok
  Let esi=Mid$(edi, 2, 1)+"/"+Mid$(edi, 2, 1)      ; crappy result
  PrintLine "[", esi, "]"      ; 2xMid$ etc failed miserably before 20.10.2015
  Exit
end start


In short, using Left$, Mid$ or Right$ twice with the same string as in Let My$=Left$(some$, somect)+Left$(some$, somect) caused trouble.

Sorry for the inconvenience. To compensate, I've improved the "Tiny GUI demo" that appears in menu File/New Masm source (34 lines of code, sizable window):

jj2007

MasmBasic update of 23 October 2015 features major changes under the hood:
include \masm32\MasmBasic\Res\MbGui.asm ; OPT_Icon Plot
  Dim MySinus() As REAL8
  For_ ct=-400 To 400
SetFloat MySinus(ct+400)=Sinus(ct) ; *** a GUI demo in 24 lines of code ***
  Next
Event Paint
  ArrayPlot hWnd, RgbCol(192, 222, 255) ; init & set background
  ArrayPlot MySinus(), 0, lines=5, 00100204h ; draw the array
  ArrayPlot exit, "Playing with Sinus() plots" ; finish with a title
  For_ ct=20 To GuiWidth-20 Step 10
GuiLine 50.0, 3.0+25, ct, 99.0, RgbCol(255, 160, 160) ; the 'pink pyramid'
void Cosinus(ct) ; load cos(ct) into ST(0)
fimul GuiHeight
fiadd GuiHeight ; center
fmul FP4(0.4)
SetInt ecx ; convert result to integer
GuiText ct+30, ecx+60, Str$(ct), bcol RgbCol(192, 222, 255)
GuiCircle ct, ecx+70, 1.5, b Rand(0ffffffh), p RgbCol(80, 80, 80)
  Next
  GuiEllipse 32.0+9, 10.0+35, 7.0, 8.0, b RgbCol(255, 128, 128) ; RGB for n00bs
  GuiEllipse 60.0-9, 10.0+35, 7.0, 8.0, b 0FF2020h, p 808080h ; BGR for experts
  GuiTextBox 50.0-70, 40.0, 140, 96, Str$("Painting took %i ms. This is just a simple text box, you can do the same in other programming languages", GuiMs), bcol RgbCol(255, 255, 192)
  GuiCircle 50.0, 40.0+50, 12.0, p 0, b none ; none = hollow brush
EndOfCode


The window is sizable and flicker-free. The template is available via RichMasm's File/New Masm source list of templates, it's the "more" link behind "Tiny GUI demo".

RichMasm has now a full word search option, for distinguishing e.g. between edi and immediate. In the upper right corner, the FW check box switches it on (in case the toolbar is not wide enough to see the FW, press Ctrl G, type tbw=150 and hit Enter).

jj2007

Update 30 October 2015 features minor improvements, inter alia the recognition of quoted strings like "123" and '123' as valid number formats, see StringToArray in \Masm32\MasmBasic\MbGuide.rtf:

      ; convert string to a numerical array:
      include \masm32\MasmBasic\MasmBasic.inc
      SetGlobals a1$="123 27.5 28.49 -56.78 '20h' 0x40 11111b/123456789"      ; string with a wild mix of number formats
      Init
      Dim MyDw() As DWORD
      For_ ecx=0 To Fn(StringToArray a1$, MyDw())-1      ; strings to dwords conversion
            PrintLine Str$("MyDw(%i)=", ecx), Str$(MyDw(ecx))
      Next

      EndOfCode


Output:
MyDw(0)=123
MyDw(1)=28
MyDw(2)=28
MyDw(3)=-57
MyDw(4)=32
MyDw(5)=64
MyDw(6)=31
MyDw(7)=123456789


Notes:
- StringToArray returns #elements in eax; in For_ ... Next loops, you may use Fn(...)-1 as shown above
- numeric arrays must be declared (BYTE ... QWORD, REAL4/8/10), but there is no need to Dim a string array before

jj2007

Update 6 November changes the display of file timestamps (more). Files that were modified during Daylight Saving Time now show the correct time, identical to the one displayed by Windows Explorer (which is in contrast to time shown by DOS and some file managers).

jj2007

MasmBasic update 21 Nov 2015 (download) features several improvements under the hood. Check (in MbGuide.rtf) in particular the TimeSF and IsoWeek functions.

The RichMasm editor crashed on rare occasions when inserting a hyperlink with Ctrl K. This is fixed now.

jj2007

Sometimes people post Hello World "projects" distributed over a dozen files. Apparently it looks more professional to put the three PROTO lines into separate include files.

When installing MasmBasic (e.g. the latest version), the first thing you'll see after clicking Accept & Install is the file MbGuide.rtf loaded with the RichMasm editor, as shown below (shortened).

Click the link "try 90+ snippets" to open MbSnippets.asc, a collection of over 90 "projects" (second image below). MasmBasic's editor has a very special feature: If the command Init is selected and you hit F6, it checks if there is an include ... line before and an end start or EndOfCode line afterwards. If both are found, the editor exports only the code between the two lines.

While the listbox has the focus, you can use cursor up/down to scroll through the "projects", which demonstrate some of the over 200 MasmBasic commands. If you see an interesting command, just hit F6 to see it in action :biggrin:

jj2007

As a complement to GetRegKeyArray and GetRegArray:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Print "ct", Tb$, "ID", Tb$, "path"
  For_ n=0 To GetProcessArray(?)-1
      Print Str$("\n%i\t", n), Str$(MbProcID(n)), Tb$, MbProc$(n)
  Next
  Inkey CrLf$, "--- hit any key ---"
EndOfCode


Output:
ct      ID      path
1       324     \Device\HarddiskVolume3\Windows\System32\smss.exe
2       692     \Device\HarddiskVolume3\Windows\System32\wininit.exe
3       752     \Device\HarddiskVolume3\Windows\System32\services.exe
4       772     \Device\HarddiskVolume3\Windows\System32\lsass.exe
5       780     \Device\HarddiskVolume3\Windows\System32\lsm.exe
6       888     \Device\HarddiskVolume3\Windows\System32\winlogon.exe
7       924     \Device\HarddiskVolume3\Windows\System32\svchost.exe
8       992     \Device\HarddiskVolume3\Windows\System32\nvvsvc.exe
...


Source & exe attached, building requires latest MasmBasic version.

Oliver Scantleberry

Quote from: jj2007 on May 23, 2012, 10:16:07 PM
MasmBasic is a library that allows to use BASIC syntax in assembler. . .

This is absolutely brilliant! I have been programming Intel processors in Assembly Language since 1975. In fact, hand-assembling the first few years. What I have always dreamed of, is using Microsoft 4k Basic syntax in assembly. Wow! This guy JJ is just awesome! He knows what everybody wants! I am thrilled!

dedndave

i think Jochen has a new fan   :biggrin:

jj2007

At least one :P

Quote from: Oliver Scantleberry on November 28, 2015, 03:08:25 PMHe knows what everybody wants! I am thrilled!

Thanks, although I am not so convinced ::)
I would be stinkin' rich if that bold statement was true :bgrin:

jj2007

MasmBasic version 2 December '15 features two new templates called Scintilla+RichEdit and WebCam. The latter is a bit long to post here, but here is a choice of three edit controls (plus a listbox) in less than 20 lines:

include \masm32\MasmBasic\Res\MbGui.asm      ; OPT_Icon Smiley
  GuiControl MySci, "scintilla", h 333, w 750, text "Привет, это контроль Scintilla"      ; h 333 = 1/3 of height
  GuiControl MyEdit, "edit", y 336, h 333, w 750, text "Это нормальная управления редактирования."
  GuiControl MyRich, "richedit", y 672, h 333, w 750, text "Это контрольный RichEdit."
  GuiControl MyListbox, "listbox", x 750, w 250
  GetFiles *.asm             ; fill Files$() array
  SortFiles                  ; most recent on top
  SetListbox "** select a file **"
  SetListbox Files$()
  SetGlobals cursel, f$
Event Command
  .if IsTrue(LbSel ne cursel) && signed LbSel>0
      m2m cursel, LbSel
      Let f$=FileRead$(LbSel$)
      SetWin$ hMySci=f$, sci
      SetWin$ hMyEdit=f$
      SetWin$ hMyRich=f$
  .endif
GuiEnd


As you can see above, Unicode is fine for these controls, and with MasmBasic's RichMasm editor you can type Chinese or Russian or whatever directly into the source code.

The snippet assumes \Masm32\wscite\SciLexer.dll; add YOUR path before the GuiControl if needed, for example:
ScintillaPath equ "\Masm32\bin\SciLexer.dll"

The Scintilla DLL is available here, see "A full download (1200K) includes the SciTE executable, any required DLLs". Extract to \Masm32\ to get the wscite folder and SciLexer.dll (the only file you need from the package to run the three edit controls example)

jj2007

MasmBasic update 12 Dec 2015 features a major change under the hood: GetFiles returns now UTF-8 file names. This has no effect on file names using only Ansi characters, but it is a major improvement for those who use Russian, Chinese or Arabic file names (and that is quite a lot of people...). The snippet below shows its usage:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  SetCpUtf8
  GfCallback MyCb      ; set callback function for GetFiles
  GetFiles \Masm32\*.bas|*.inc|*.as?|*.rc      ; fill the Files$() array
  PrintLine Str$("\n%i files found. Newest files:\n", eax)
  SortFiles                  ; new files on top
  For_ ecx=0 To eax-1
      lea edx, [Files$(?)-10]      ; somearray(?) means #elements
      .if ecx<10 || ecx>=edx
            If_ Zero? Then PrintLine CrLf$, "Oldest files:"
            PrintLine Str$(GfSize(ecx)), Tb$, GfDate$(ecx), Spc2$, GfTime$(ecx), Tb$, Files$(ecx)
      .endif
  Next
  Inkey "---- hit any key ----"
  Exit

MyCb:            ; simple callback: ecx is file counter, esi current file in Unicode format
  If_ wInstr(esi, wChr$("msv"), 1) Then wPrintLine esi      ; demo for filtering output
  ret
end start


Output (shortened):
comsvcs.inc
msv1_0.inc
msvcrt.inc
msvcrt.inc
msvcrt

8868 files found. Newest files:
327013  12.12.2015  01:14:55    \Masm32\MasmBasic\MasmBasic.inc
1985    12.12.2015  01:13:22    \Masm32\MasmBasic\AscUser\NewSources.asc
1032520 11.12.2015  11:25:24    \Masm32\RichMasm\RichMasm.asc
620     11.12.2015  08:18:32    \Masm32\MasmBasic\TestMasmBasic.rc

Oldest files:
288     07.09.1998  14:17:58    \Masm32\examples\exampl01\filtinpt\rsrc.rc
288     07.09.1998  14:17:58    \Masm32\examples\exampl01\comctls\rsrc.rc
288     07.09.1998  14:17:58    \Masm32\examples\exampl01\dll\loaddll\rsrc.rc
288     07.09.1998  14:17:58    \Masm32\examples\exampl01\3dframes\rsrc.rc
288     07.09.1998  14:17:58    \Masm32\examples\exampl01\dll\calldll\rsrc.rc


The snippet shows also how to use a callback function for GetFiles. If you return -111 in ecx, the current file will not be added to the Files$() array. Source & exe attached. Feedback, in particular from non-English members, appreciated :t