Author Topic: MasmBasic  (Read 415544 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13289
  • 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)
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13289
  • 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:
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13289
  • 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.
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13289
  • 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.
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.