Projects > MasmBasic & the RichMasm IDE


(1/85) > >>

BASIC is the Best Approach to Simple and Intelligent Coding. MasmBasic is a library that allows to use BASIC syntax in assembler, i.e. it is not a "separate" language but rather a library of macros and routines, fully compatible with the latest Masm32 SDK (version 11), MASM (version 6.15 and higher, e.g. version 8.0) and JWasm/HJWasm, and thoroughly tested on Windows XP, 7, 8 and 10.

While MasmBasic is pretty stable (and pretty fast - typically twice as fast as C), it is still Assembler, therefore the usual disclaimers apply - do not use for military purposes, in hospitals and anywhere else where buggy applications could cause damage. You have been warned 8)

To install the library, double-click SetupMasmBasic.exe in the attached archive (see step-by-step instructions).

For an overview of the about 200 functions available, see \Masm32\MasmBasic\MbGuide.rtf (after extracting the archive, of course) or see the (incomplete) MasmBasic Quick Reference online. See also A guide to the RichMasm editor.

4 October 2017: Updated archive attached below, now with MemState for finding leaks, Math symbols in RichMasm, PrintRtf, dual 32/64-bit examples in File/New Masm source menu, and a 64-bit version of the deb macro. Older changes: For_ each x$ in My$(), improved Switch_; GetFiles returns UTF8 now; WebCam, GetProcessArray(), new GSL lib, Choose, fast MemSet, Instr_() and Sinus() added, GuiTextBox improved. Data and Read , float counters are valid in For_ ... Next, and xmm regs are preserved for all MasmBasic commands. Note that simple Windows API calls can trash them on 64-bit versions of Windows.
Latest additions: GuiXX functions, Split$, Join$, Filter$, commandline to Files$(), GfCallback, true Unicode, also in file I/O; UnzipFile, ArraySet, SetReg64 for 64-bit registry settings, ArrayMerge, Age(), GetRegArrays, unsigned LONGLONG in Str$(), ShEx, xls interface, ArraySet, ArrayPlot, AddWin$, WritePipe, Plugins, IsFolder(), wOpen, FileOpen$/FileSave$, also as Unicode versions, Extract$, Dialogs, COM support (CoInvoke, GuidsEqual(), IUnknown, VARIANT, ...), improved ANSI and Unicode commandline macros CL$()/wCL$(), improved xHelp, Launch$(), Try/Catch/Finally, ...

Installation hints for Windows 8 ... 10:
- click on below
- depending on your browser and zip application, choose open in xyZip or Save as...
- if it doesn't open in 7-zip or WinZip or whatever, locate the zip file and open it
- once you see SetupMasmBasic.exe, open it (double-click or Enter)
- you should see an extraction dialog, and shortly after a box "Windows Protected Your PC - Windows SmartScreen prevented..."
- do NOT click OK; instead, click on the tiny green link "More info"
- you will see Program SetupMasmBasic.exe and "unknown publisher"; click "Run Anyway"
- the screen will darken, and you see a box "Do you want to allow .. changes to your computer?"
- click Yes
- you should see now a big box "MasmBasic - a fast library..." with a EULA; read it, then click "Accept & Install"
** if anything goes wrong, disable your antivirus and try again; if that doesn't help, reply to this thread **


This snippet (a full-fledged Windows console application  :biggrin:) produces the following output:
Введите строку, которую вы хотите найти в папке \Masm32\Include: bitmap
#1      \Masm32\Examples\advanced\wrep\result.asm
#2      LOCAL tbab   :TBADDBITMAP
#3      \Masm32\Examples\advanced\wrep\richedit.asm
#4      LOCAL tbab   :TBADDBITMAP
#5      \Masm32\Examples\Bill_Cravener\calender\calendar.asm
#96     \Masm32\Examples\exampl02\appack\toolbar.asm
#97     LOCAL tbab  :TBADDBITMAP
#98     ; The toolbar bitmap
#99     ; You must supply a bitmap for the toolbar that ha
#100    \Masm32\Examples\exampl02\appack\rsrc.rc

As the example shows,
    1. MasmBasic is not BASIC: No BASIC dialect understands mov ebx, 400
    2. MasmBasic is assembly, i.e. it will flawlessly assemble with Microsoft Macro Assembler (MASM, version 6.15 upwards) or, better, with Jwasm

Here is a more complex application. It opens, converts all hexadecimal equates into decimal ones, and writes it back to disk:

--- Code: ---include \masm32\MasmBasic\

call Convert

Convert proc
LOCAL pos, posAfter, MyTimer, MyCounter
  and MyCounter, 0
  mov MyTimer, Timer
  Recall "\Masm32\include\", L$() ; load an array of strings from file
  mov ebx, eax
  For_ n=0 To ebx-1
mov pos, Instr_(1, L$(n), "equ", 5) ; start in pos 1, 1=case-insensitive + 4=full word
.if pos
mov esi, Val(Mid$(L$(n), pos+3, 99)) ; get the numeric value of the string behind equ
.if signed edx<0 ; edx returns the number of usable chars; a
neg edx ; negative number indicates a hex$ or bin$ was found
add edx, pos
add edx, 3
mov posAfter, edx
inc MyCounter
Let L$(n)=Left$(L$(n), pos-1)+"EQU "+Str$(esi)+Mid$(L$(n), posAfter)
  Store "", L$() ; write all strings back to file
  sub MyTimer, Timer
  Print Str$("\nConverting %i hex equates in to decimals", MyCounter), Str$(" took %i ms\n", 0-MyTimer)
Convert endp

end start
--- End code ---

Converting 7676 hex equates in to decimals took 31 ms

MasmBasic comes with RichMasm. The editor is configured to give context-sensitive help with the F1 key, and to expand many instructions. For example,
opo [space] will expand to Open "O", #1,
mb becomes MsgBox 0, "¨", "Hi", MB_OK
for_ becomes For_ n=0 To ebx-1 ... Next
ism becomes invoke SendMessage,
 etc.; more in \masm32\MasmBasic\MbGuide.rtf (in RichMasm:  File/MasmBasic Guide)

Last but not least an ultra-short Win32 application  ;)

--- Code: ---include \masm32\MasmBasic\
end start
--- End code ---

Let me know who is missing  :biggrin:

I wrote this library for my own use and pleasure, but since many forum members contributed to it, through good advice and even better algos, I think it is just fair to release it here. Thanks to everybody :icon14:

For the xHelp project, I had to add a few functions - sorry if you tried to assemble xHelp.asc with the June version. Among others, these features have been included:

   ; the line below launches Arc.exe with option v and returns what SdtOut produces:
   Let esi=Launch$(ExpandEnv$(Chr$(34, "%ProgramFiles%\FreeArc\bin\Arc.exe", 34, " v Lib32.arc")))   ; see FreeArc
   StringToArray esi, FreeArc$()   ; translate linear output to an array
   For_ ebx=0 To eax-1
      PrintLine Str$(ebx), Tb$, FreeArc$(ebx)
Rem   args as in Launch above; returns string in eax

0       FreeArc 0.666 listing archive: Lib32.arc
1       Listing archive: Lib32.arc
2       Date/time              Attr     Size          Packed      CRC Filename
3       ----------------------------------------------------------------------
4       2000-06-02 16:24:14 .......     1364           10002 c2249beb Masm32\m32lib\a2dw.asm
5       2004-05-21 07:38:48 .......     3399               0 50c16759 Masm32\m32lib\a2dw_ex.asm
41      2003-12-06 08:43:10 .......     4843            1097 b83a653e Masm32\m32lib\ascdump.asm
42      ----------------------------------------------------------------------
43      38 files, 77,396 bytes, 11,099 compressed

   Let esi="Recent Unread Topics"
   Print esi, " was launched by ", ExeFromWin$(WinByTitle(esi))   ; by firefox.exe, of course ;-)
Rem   returns full path of executable that created a window

SetGlobals   ; declares global variables relative to ebx, syntax as in LOCAL
   whatever   dd ?
   SetGlobals hMain, hStatic, hEdit
   SetGlobals hMenu, hM1, hM2, rc:RECT
   SetGlobals msg:MSG, wc:WNDCLASSEX, exeBuffer[MAX_PATH]:BYTE, gBuffer[1024]:BYTE
   ; no args: set ebx to the right offset; must be used in Init part and all callbacks (WndProc, SubEdit, ...)
Rem   variables return [ebx+x]

Enum      ; create a list of IDs
   Enum   IdMenuNew, IdMenuSave, IdMenuCopy, IdTimer
   Enum   20:IdEdit, IdButton1, 30:IdButton2, IdStatic, IdFind, IdFindStatic
Rem   - variables return [ebx+x]
    - default start is 10, but different start values can be specified

Hi jj2007. Nice library. Are you not worried when you need to convert this thing to 64 bit code?  :icon_confused:

How many users worldwide is using this library?


--- Quote from: CodeDog on September 11, 2012, 12:01:25 PM ---Hi jj2007. Nice library. Are you not worried when you need to convert this thing to 64 bit code?  :icon_confused:

--- End quote ---
Win7-64 still runs 16-bit code. Guess how old I'll be when Windows stops supporting 32-bit code :greensml:

--- Quote ---How many users worldwide is using this library?
--- End quote ---

Be the first. It's faster than your favourite C dialect...


[0] Message Index

[#] Next page

Go to full version