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

Richard


Just getting some practice before I start writing my own code. I tried the following example (first time for examples) and F6 gave the following error.

I may have some residual MASM5.1 (and more recently MASM 6) stuff floating around - so before I start changing/deleting things I better ask! Note that ALL my MASM5.1 (+ MASM 6) stuff existed before I ever heard about RichMasm and MASM32 SDK.


*** Start C:\Masm32\MasmBasic\Res\bldallRM.bat ***
*** 32-bit assembly ***


*** Assemble, link and run SkelTimer ***

*** Assemble using ml  ***
Assembling: tmp_file.asm
##########################

You CANNOT use the MasmBasic library with
the old ml.exe version 6.14 - use UAsm instead

##########################
*** MasmBasic version 18.02.2021 ***
*** Warning: SQWORD is unsigned with ml **
\masm32\MasmBasic\MasmBasic.inc(728) : error A2052: forced error
TestMasmVersion(8): Macro Called From
  \masm32\MasmBasic\MasmBasic.inc(728): Include File
*** Assembly error ***


jj2007

Hi Richard,

how did you force RichMasm to use ML? With OPT_Assembler ml? The error message is clear, MasmBasic won't accept the old assembler, for good reasons. So if \Masm32\bin\ml.exe is an old version, you get that message.

By default, RichMasm wants ?:\Masm32\bin\UAsm64.exe, but with e.g. ; OPT_Assembler AsmC you can work with another one.

Do you have the latest UAsm, see http://www.terraspace.co.uk/uasm.html#p2, to be extracted as \Masm32\bin\UAsm64.exe?

I have no experience with any pre-MASM 6.14 code, can you post a short example? Perhaps I can make it run...

Richard

@jj2007

Thanks for reply - would have answered sooner (for some reason your email ended up in junk mail and so did not know).

Refer attachment

All I wanted to do was to try programs from the forum (refer last two images) to gain a bit of practice (with code that works) before trying out my original code.

(Keeping in mind that I am still getting used to my 3200x1800 display in high DPI mode (scaling 100) and as you mentioned only some parts I can scale up (to be readable) with Ctrl Mouse  wheel but system fonts can not be.  So the "mixed sizes" is OK (needs getting used to) but until I practice a lot more, it is easy for me to accidently click in error. Also, I am getting used to selection from top menu bar is not aligned to context columns (as you acknowledged earlier - it is very tricky to code especially when one (you) does not have a high DPI display.

First, just for fun, I wanted to try out the unicode ascii file program - loaded the .asc file from the forum and pressed F6 (not adjusting any settings or anything). A black DOS-like command screen appeared and a little pop-up window saying something to the effect that if some unicode characters do not appear correctly ... then to try Lucinda Console (or something similar sounding). So I immediately went to Settings>Personalize>Fonts> and selected Lucinda Console. I returned to the unicode program console window - but it looked like something "locked up" with it - so I tried to completely close down the program (and RichMasm) but no response. Not even Windows Task Manager OR Task Bar could close it! I could not even move that window around (out of the way of other applications running). "a.asc" was just a temporary "save" just to allow from earlier on, to close RichMASM application - I was not actually wanting to do anything with a.asc - just to close off RichMASM (I got confused with something earlier - so best to start with a "clean slate").  RichMASM locked up with the first image window (keep in mind I was trying to click my way out - so who knows what I may have triggered off.

So I SHUTDOWN my computer, checked that the Lucina Console font was active (according to windows), launched RichMASM and opened up Unicode_File_Names.asc and so the Unicode_File_Names.asc appeared to work OK (just pressing F6 in RichMASM IDE).

I went to the second example program SkelTimer.asc and pressed F6 and the error message as above appeared.

So the "lock up" confused me, I probably did some wrong key presses trying to exit. (I think maybe changing the font and not restarting first also added to the confusion).

I was not attempting to load any old MASM (5 and 6) stuff - however they are still lingering around (maybe I should permanently remove - since I am no longer using DOSBOX and MASM5.1 (RichMASM has "spoilt me")). However it is quite possible that some directories (eg MASM) is loaded up with MASM5.1 stuff and MASM32 SDK stuff etc (I have not checked out for this double useage of directory).

I hope you have enough info from me to see what went wrong - I do not think there is anything wrong with RichMASM.

jj2007

Hi Richard,

I can't solve the font problems for anything outside the main editor window (listbox, Find+Replace, bookmarks etc) for the time being. Regarding the main editor window, you already know the mouse wheel trick, and I suppose you hit Alt Z to save the zoom level. One more hint: There are templates that use the System font, which is not zoomable; press Ctrl A to select the whole text, then Ctrl L twice. This changes the whole text to a zoomable flavour. Ctrl Shift L selects an extra large text btw - I use that for macro and proc names.

Re freezing: I've experienced that in recent months, and the culprit is Firefox in my case. It happens after a long (5-10 hours) session, and it freezes indeed everything. Normally it goes away after a few minutes. I doubt that RichMasm has any role in it, as its memory usage is tiny compared to a browser.

Thanks a lot for your feedback :thup:

Richard

Thanks for reply.

I understand and appreciate re sizes - that is a major reason why I want to "practice" with code that works, so to get "used to" and be "comfortable with" with everything.

I use windows 10 x64 build 2H20 and all sorts of "weird things" quite often happen - the latest is that for a few months now, when I run my computer for a long time (1-3 days continuously) number crunching - I will most likely get a "black screen" , no mater what I try and screen won't come back (and my programs are still running). In these cases I have to press and hold the power key for 10 seconds (the most drastic shutdown procedure).

On this occasion, my computer has been running about 2 days (and the black screen not yet occurred) - so maybe changing the font really really messed up windows).

I will "sleep over it" and start from scratch re example programs before I will download any UASM stuff (I am not planning on going "backwards" (from RichMASM) so after a lot more practice with examples from this forum and RichMASM then will try my own code writing solely using your IDE and F6.

Just a side note, if you don't mind me asking, are you "in the know" about - GNU gcc, Intel syntax versus AT&T syntax, Geany. The reason why I ask is that once I get relatively small and simple sounding MASM projects up and going (in RichMASM) - that I will port the code into a (other) High level language via include files but the preferred way is via gcc and at that using intel syntax (my ultimate aim, the "other" high level language occupies 99% of code but that code only does 1% of the work, the assembly code (technically not really "in-line assembly") occupies 1% of the code but does 99% of the work (and probably much faster)) 

jj2007

Quote from: Richard on April 05, 2021, 02:52:37 AMJust a side note, if you don't mind me asking, are you "in the know" about - GNU gcc, Intel syntax versus AT&T syntax, Geany. The reason why I ask is that once I get relatively small and simple sounding MASM projects up and going (in RichMASM) - that I will port the code into a (other) High level language via include files but the preferred way is via gcc and at that using intel syntax (my ultimate aim, the "other" high level language occupies 99% of code but that code only does 1% of the work, the assembly code (technically not really "in-line assembly") occupies 1% of the code but does 99% of the work (and probably much faster))

That's a matter of taste. I don't like C/C++, and I can produce what I need much faster with Basic syntax. I've tried FreeBasic, but it's an awful mess of "toolchains" and "backends", and on the FB Forum 90% of the discussion is about problems compiling some code with the Gas, Gcc, whatever backend. No thanks. In Assembly, the number of instructions is limited, and the machine does exactly what I tell it to do :cool:

Try doing this in C or C++ (you can drag a .txt, .asm, .rtf or .asc file over the exe):
GuiParas equ "Controls", xr20, w500, h200, icon Info, bBlue, m7
GuiMenu equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyEdit, "RichEdit", wCL$()
  GuiControl MyStatus, "statusbar", "Hello"
Event Command
  If_ NotifyCode==BN_CLICKED Then SetWin$ hMyStatus=Str$("Button or menu #%i clicked at ", MenuID)+fTime$(0)
GuiEnd

jj2007

After exactly one year, MasmBasic was updated today. Inter alia, the StackWalk and profiling macro might be interesting for members with somewhat bigger projects.

jj2007

Version 20 February has one small change against version 18 February:

- with e.g. Declare SomeFunction, 2 passing a string and an immediate as in SomeFunction("Test", 123.456)
  will pass a REAL4 as second argument; to force a double, use SomeFunction("Test", REAL8:123.456)


In the new versions, the editor RichMasm has built-in profiling:
- press F9
- hold Ctrl
- click "No"

jj2007

Version 12 March is online, now with almost 500 commands.

GuiParas equ "Rtf viewer", w700, h600, m0, b none, icon Butterfly      ; position, margins, background colour
include \masm32\MasmBasic\Res\MbGui.asm
  GetFiles *.as?|*.rtf|*.inc    ; load whatever fits your needs
  SortFiles name                ; could be also date (recent on top) or size (big ones on top)
  GuiControl MyList, "listbox", Files$(), x=1000-120, w=0+120   ; leave some space to the right
  GuiControl MyEdit, "RichEdit", FileRead$(Files$(0)), bcol RgbCol(120, 120, 120), fcol White, w1000-120, font -14:FW_SEMIBOLD
  GuiControl MyStatus, "statusbar", wRec$("Started "+fTime$())

Event Command
  .if NotifyCode==LBN_SELCHANGE
     SetWin$ hMyEdit=FileRead$(LbSel$)       ; load selected file into the RichEdit control
     SetStatus$ Cat$("Current file: "+LbSel$+Str$(", %i bytes", LastFileSize)+", created "+GfDate$(-1))
  .endif
GuiEnd


Among the improvements is the option to give a foreground colour also to a RichEdit control (see attached source and exe):

GuiControl MyEdit, "RichEdit", FileRead$(Files$(0)), bcol RgbCol(120, 120, 120), fcol White,

This is a tricky business, because it works fine with a plain text file loaded into the RichEdit control, but what about RTF files? They have their own text colours stored in the file, but they don't have a background colour unless you explicitly apply it in your RTF editor, such as RichMasm or WordPad.

So what happens is that you tell the control "I want white text on dark background", and that works fine for plain text, but if you load a RTF file, you are stuck with the text colours chosen by the file's author. Which might be, ehm, black... :cool:

Btw the RichEdit control checks automagically if an MS Office versions of RichEd20.dll is installed on your machine. If so, it loads RTF files a factor 20-30 faster than the standard RichEd20 in Windows\System32. That doesn't matter if your files are tiny, but when they approach the megabyte range, it surely makes a big difference. The RichMasm source, for example, with 1.4 MB, loads in less than a second on my trusty old Core i5.

You don't need MS Office to get the fast DLLs: the old Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint installs them for free. Same for the Word viewer, I suppose.

Test it yourself: Extract the exe to a folder that has both *.rtf (or *.asc) files and plain text, such as *.asm and *.inc.

HSE

Hi JJ!

Too much talk. What you maked?
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on March 12, 2022, 02:53:19 PM
Hi JJ!

Too much talk. What you maked?

What did I do to make the fcol White work?
- SetWin$ checks if the control is a RichEdit control (GuiControl can be almost every Windows control)
- if so, it checks for the \rtf string at the start of the file to be read in
- if it's plain text, it sends an EM_SETCHARFORMAT message

Then there is a MbLoadRich proc that checks for the presence (in this order) of...
- RichEd20.dll in the executable's folder
- %CommonProgramFiles%\Microsoft shared\Office11\RichEd20.dll
- %CommonProgramFiles%\Microsoft shared\Office12\RichEd20.dll
- %WinDir%\System32\RichEd20.dll

You can force another version using mov RichEditUsed, <path>, and you can check which version was used with a...

  MsgBox 0, RichEditUsed, "Your Dll:", MB_OK

... before the Event Command. Simple, right? It can be even simpler; this is a full-fledged rtf viewer in three lines (see CL$()):

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyEdit, "RichEdit", FileRead$(CL$()), bcol Black, fcol White
GuiEnd

HSE

 :thumbsup:  Thanks.

I'm developing a different approach for small files.
Equations in Assembly: SmplMath

jj2007

MasmBasic version 11 May 2022 is online. Mostly minor cosmetics, but there are also some significant changes under the hood:

1. Str$(someDword) has become blazingly fast, see The joy of beating the CRT by a factor 10 in the Laboratory.

2. Same for Instr_(haystack, needle) - it beats the Boyer-Moore algos now most of the time (and CRT strstr by a factor 10) :cool:

3. MasmBasic's editor RichMasm (part of the package) now supports Hutch' brand new Masm64 SDK. Just open a source, e.g. \Masm64\Examples\Advanced\JpgTool\JpgTool.asm and hit F6 :thumbsup:

Feedback please, I need to know when things don't work  :biggrin:

P.S.: I made some minor changes today. You have the correct version if the zip file is named SetupMasmBasic11May.zip, and there is a link to the Masm64 SDK in the MasmBasic help file at the top of the second "Hello World" example:

include \masm32\MasmBasic\Res\JBasic.inc        ; instead of JBasic, you might try the Masm64 SDK

jj2007

MasmBasic version 20 May 2022 is online. Significant changes:

- RichMasm handles better the case that you "forgot" an active program, e.g. by not answering to an Inkey ("hit any key"); it will present a MessageBox asking if you want to kill the current instance before building the new version.

- improved cycle count macros:

  include \masm32\MasmBasic\MasmBasic.inc
  Init
  CyCtInit
  CyCtStart
        fldpi
        fmul FP8(100.0)
        fdiv FP4(10.0)
        fstp st
  CyCtEnd PI*100/10             ; describe what the code does
  EndOfCode


- output is e.g. 17 Cycles for PI*100/10
- without description after CyCtEnd, 1,000 individual cycle counts are accessible through the CyCt() DWORD array
- using CyInit store, the counts are saved to the CyCt$() array (see Store for saving the array to disk)

jj2007

Version 30 May 2022 is online, with several minor improvements, inter alia of NoTag$():

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  FileWrite "test.tab", NoTag$(Clip$())         ; get html from the clipboard, convert to plain text
  ShEx "test.tab"                               ; launch the application associated with *.tab (often Excel)
EndOfCode


Source & exe attached. To test it,
- go to a site that has tables, e.g. https://www.tiobe.com/tiobe-index/ or http://masm32.com/board/index.php?action=stats
- press Ctrl U to see the html source
- press Ctrl A, Ctrl C to copy the source
- launch the attached executable

The output file test.tab will open e.g. in Excel. On my machine, it will look like this:



As you can see, row #5 is slightly off - sometimes the tab files may require some editing. Another example, exported from https://www.stackscale.com/blog/popular-programming-languages-2021/ and imported into M$ Excel:



I attach a sample tab file extracted from WorldoMeters. Most Wikipedia tables should work, too - please inform me if you find one that doesn't. Note it will not work on sites that use scripts to generate tables, such as this World Bank page.

The ancient Internet Explorer used to have the option to export a table; no idea why they abolished it :cool: