Author Topic: MasmBasic  (Read 425306 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #555 on: May 20, 2022, 10:12:02 AM »
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

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #556 on: May 31, 2022, 06:23:13 PM »
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:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
MasmBasic updated, with some new features
« Reply #557 on: October 02, 2022, 10:25:53 AM »
Version 2 October is online :biggrin:

It's over 500 macros now. Here are the additions since November 2020:
Code: [Select]
SetLaunchEnvironment
Ini$
Cls
_Passed$
Arctangens
rTangens
Tangens
rCotangens
Cotangens
ArcSinus
rArcSinus
Cosinus
rCosinus
Tangent
FontExist
WinByClass
WinFromID
WinFromID$
MbProfile
WarmUp
CyCtInit
CyCtStart
CyCtEnd
SetWatch
swShow
swEnd
StackWalk
SWalkP
SWalkE
@FP4
@FP8
@FP10
GuiImageSet

With a handful of exceptions, they are documented in \Masm32\MasmBasic\MbGuide.rtf; search e.g. for .MbWinByClass

The most recent addition are coloured pushbuttons:
Code: [Select]
GuiParas equ "Colourful buttons", w320, h110 ; 32% of window width, 11% of height
; GuiButtonPen equ <MakePen MbBtnPen, RgbCol(128, 255, 255, 255), width 3> ; white, half transparent
include \masm32\MasmBasic\Res\MbGui.asm ; select GuiParas and hit F6
  GuiControl Button1, "button", "That's a normal pushbutton", w250, h0+40 ; width 25% of client area, height 0%+40px
  GuiControl Button2, "button", "Lite Turquoise"/"Blue", bcol LiteBlueGreen/Blue, x250, w250, h0+40, font -14
  GuiControl Button3, "button", "Lite Yellow"/"Full Yellow", bcol LiteYellow/Yellow, fcol Red/Black, x500, w250, h0+40, font -14:FW_BOLD
  GuiControl Button4, "button", "Rounded button", bcol LiteGrey/Red, fcol Black/White, rr40, x750, w250, h0+40, font -12:FW_SEMIBOLD
GuiEnd

Rem To define a button, use:
- x, y, w, h for its position, followed by n 1000th of the window width or height
- bcol RgbCol(...) to define the background colour; bcol Blue/Red means "blue, but red if pressed"
- fcol Black/White to define the foreground (text) colour; white if pressed
- "normal text"/"pressed text"
- rr0=no rounded corners, rr100=a circle; use guiRoundRect=n to set the default rounding
- you may define a pen: put GuiButtonPen before the include line

With 7 lines of code, you can create this:



These buttons require an XP manifest, as shown in the attachment. When you size the window, the buttons size horizontally but not vertically, due to the w250, h0+40.

If you zoom in the image below, you may notice that the buttons' borders use antialiasing: under the hood, Gdi+ is at work.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
MasmBasic updated
« Reply #558 on: November 15, 2022, 11:01:21 PM »
MasmBasic version 15 Nov 22 is online. The included RichMasm editor will now colourise plain text asm sources to a certain extent, like in this example from \Masm32\examples\threads\multhread\multhrd.asm:

WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

    LOCAL tID    :DWORD

    Switch uMsg
      Case WM_COMMAND
        Switch wParam
          Case 50
          ; ------------------------------------
          ; loop through starting 10 new threads
          ; ------------------------------------
            push esi
            push edi
            xor esi, esi
            xor edi, edi
          @@:
            add esi, 25
            add edi, 1
            fn CreateThread,0,0,ADDR CreateNewThread,esi,0,ADDR tID
            cmp edi, 10
            jl @B
            pop edi
            pop esi

          Case 51
          ; ----------------
          ; close all thread
          ; ----------------


All push arg and pop arg instructions are highlighted in red. Jumps to @@: labels are red for @B and blue for @F. Such a few red spots can help to recognise, for example, problems with stack balance. I am not a fan of Christmas trees aka automatic highlighting of each and every little feature, but I do use manual colouring in my sources, especially when doing little tricks, see below.

When saving the source code in RTF format (as *.asc), these changes are permanent.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Santa Claus edition is online
« Reply #559 on: December 06, 2022, 11:18:30 AM »
Install the latest MasmBasic version to get access to over 500 powerful macros, and in case you want to build the Simple Editor. Latest items:

Guid$():
Code: [Select]
Let edi=Guid$()
MsgBox 0, Cat$("A Guid: ["+edi+"]"), "Hi", MB_OK

Output: A Guid: [d6e3dc8a-f76a-4ec2-9163-65f8bdd0138f] (plus a pointer to the GUID itself in edx)

xCall for passing arguments to a label, invoke style:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
.code
somelabel:
mov ecx, [esp+4]
MsgBox 0, ecx, "Hi", MB_OK
retn 4
Init
xCall somelabel, Chr$("Hello World")
EndOfCode

MsgBox: see http://masm32.com/board/index.php?topic=10530.msg116251#msg116251, the new MsgBox will not make your controls lose the focus.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #560 on: December 07, 2022, 03:38:35 AM »
I forgot this one: CenterWindow hWnd_, 400, 200  ; 400px wide, 200px high, right in the middle

LiaoMi

  • Member
  • *****
  • Posts: 1046
Re: Santa Claus edition is online
« Reply #561 on: December 08, 2022, 05:12:12 AM »
Install the latest MasmBasic version to get access to over 500 powerful macros, and in case you want to build the Simple Editor. Latest items:

Guid$():
Code: [Select]
Let edi=Guid$()
MsgBox 0, Cat$("A Guid: ["+edi+"]"), "Hi", MB_OK

Output: A Guid: [d6e3dc8a-f76a-4ec2-9163-65f8bdd0138f] (plus a pointer to the GUID itself in edx)

xCall for passing arguments to a label, invoke style:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
.code
somelabel:
mov ecx, [esp+4]
MsgBox 0, ecx, "Hi", MB_OK
retn 4
Init
xCall somelabel, Chr$("Hello World")
EndOfCode

MsgBox: see http://masm32.com/board/index.php?topic=10530.msg116251#msg116251, the new MsgBox will not make your controls lose the focus.

Hi jj2007,

Bad DLL for R? - msftEdit.dll

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #562 on: December 08, 2022, 08:41:34 AM »
Hi LiaoMi,

On my Win7-64, C:\Windows\System32\msftedit.dll accepts only RichEdit50W RichEdit60W as well as RichEdit20W. Which Windows version are you running?

Can you do me favour and test the attached version, which does an extra check? If you get it running, please hit F9 and give me the RichEdit??W version. Thanks :thup:
« Last Edit: December 08, 2022, 11:49:12 AM by jj2007 »

TimoVJL

  • Member
  • *****
  • Posts: 1261
Re: MasmBasic
« Reply #563 on: December 08, 2022, 10:07:29 AM »
My windows 7 x64 msftedit use RichEdit50W
File version: 5.41.21.2510
Inside dll is UNICODE string RichEdit50W
May the source be with you

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #564 on: December 08, 2022, 11:39:46 AM »
My windows 7 x64 msftedit use RichEdit50W
File version: 5.41.21.2510
Inside dll is UNICODE string RichEdit50W

RichEdit is driving me mad!

Code: [Select]
00000000        RichEdit20W
Impossibile trovare la classe della finestra.

001603E0        RichEdit50W
Operazione completata.

00000000        RichEdit60W
Impossibile trovare la classe della finestra.

00000000        RichEdit20A
Impossibile trovare la classe della finestra.

00000000        RichEdit50A
Impossibile trovare la classe della finestra.

Fun fact: RichMasm.exe runs just fine with RichEdit60W... and I just found out why - it loads the Office12 variant present on my machine :rolleyes:

Testbed attached, pure Masm32 SDK :cool:

LiaoMi

  • Member
  • *****
  • Posts: 1046
Re: MasmBasic
« Reply #565 on: December 09, 2022, 10:11:32 AM »
Hi LiaoMi,

On my Win7-64, C:\Windows\System32\msftedit.dll accepts only RichEdit50W RichEdit60W as well as RichEdit20W. Which Windows version are you running?

Can you do me favour and test the attached version, which does an extra check? If you get it running, please hit F9 and give me the RichEdit??W version. Thanks :thup:

Hi jj2007,

I have windows 10 Ent 21h1  :rolleyes:

---------------------------
RichMasm editor version 07.12.2022, built with UAsm64:
---------------------------

RichEdit20W of msftEdit.dll, ComCtl32 version 6.16
---------------------------
Yes   No   Cancel   
---------------------------

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13662
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #566 on: December 09, 2022, 11:25:07 AM »
Thanks a lot, LiaoMi :thup: