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

Magnum

Quote from: jj2007 on May 23, 2012, 10:16:07 PM
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 (from version 6.15 upwards, see e.g. version 8.0) and JWasm. 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)


I wish you had posted that earlier.

I used it to write a program that monitors C-eye-PAV.

I think you are safe though.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

Update 15 August (download):

Qcmp, Ocmp
.data        ; for testing
qSmall    qWORD 7700000000000001h
qBig      qWORD 7700000000000003h
oSmall    OWORD 77000000000000000000000000000001h
oBig      OWORD 77000000000000000000000000000003h        ; OWORD for JWasm and higher ML.exe versions
; oBig    qWORD 00000000000000003h, 7700000000000000h        ; 2 QWORDS for ML 6.15
.code
        Qcmp qBig, qSmall        ; compare two global variables
        mov ecx, offset oBig        ; use a pointer ...
        Ocmp ecx, oSmall        ; ... for one (or both) of them
        movups xmm0, OWORD PTR oSmall        ; even ML 6.15 understands that
        oqDeb=1        ; if this flag is set, Qcmp or Ocmp print e.g. "ecx greater xmm0" to console
        Ocmp ecx, xmm0        ; a pointer and an XMM reg (xmm0...xmm2 will be trashed)
        deb 4, "Result", flags        ; CzSo, i.e. Carry? and Sign? set
Rem
        - returns flags as in a cmp eax, edx comparison (control for overflow!)
        - trashes eax and edx, xmm0 and xmm1; do not use edx as input
        - you cannot use both ecx and ebx as input pointers (an error will be thrown)

## for comparing floats (REAL4, REAL8, REAL10): ##
Fcmp
        MyPI_hi        REAL4        3.14160
        ...
        Fcmp MyPI_hi, PI, medium        ; PI is what you think it is
        .if FcmpLesser
                Print Str$("MyPI_hi at %f is lower than the real PI\n", MyPI_hi)
        .elseif Zero?
                Print Str$("MyPI_hi at %f is exact\n", MyPI_hi)
        .else
                Print Str$("MyPI_hi at %f is higher than the real PI\n", MyPI_hi)
        .endif
Rem        - returns Zero? and Sign? flags (and only these are valid): Sign? means "first arg below second arg"
        - you may use FcmpGreater and FcmpLess (aka !Sign? and Sign?)
        - single arg, e.g. Fcmp xmm1, tests for zero
         - see also QCmp and Ocmp for comparing QWORDs and OWORDs
         - almost any number formats can be compared, including xmm registers etc

Magnum

Quote from: jj2007 on May 23, 2012, 10:16:07 PM
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 (from version 6.15 upwards, see e.g. version 8.0) and


When I clicked on version 8, it said off limits.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

Thanks, Andy - I just corrected the link to Erol's post. Caution, though, when going to the M$ site:

QuoteThe Microsoft Macro Assembler 8.0 (MASM) is a tool that consumes x86 assembly language programs and generates corresponding binaries.

Make a backup of your sources ;)

Or, much better idea, use JWasm - fully compatible with Masm32 and MasmBasic, and at least twice as fast as the latest M$ snails. RichMasm has now autodetection for JWasm:
   ; if OPT_Assembler not explicitly set, check if ML is old and JWasm is available
   .if Exist("\Masm32\Bin\ml.exe")
           .if Instr_(GfDate$(-1), "1999")
                   mov ecx, Chr$("\Masm32\bin\JWasm.exe")
                   .if Exist(ecx)
                           invoke lstrcat, edi, offset txOptAss
                   .else
                           MsgBox 0, Cat$("You need"+CrLf$+ecx), "Hi", MB_OK
                   .endif
           .endif
   .endif

dedndave


jj2007

Quote from: dedndave on August 15, 2013, 05:01:13 PM
PacMasm ?   :biggrin:
include \masm32\MasmBasic\MasmBasic.inc        ; download
        Init
        GetFiles \Masm32\*.asm
        push eax
        For_ ebx=0 To eax-1
                Kill Files$(ebx)
        Next

        Inkey Str$("Dave, wifey is waiting, and %i files are gone!!!!", stack)
        Exit
end start  :greensml:

Antariy

:greensml:



C:\MASM32\>ML the_proper_code.asm
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.

Assembling: the_proper_code.asm
Yum-yum!



C:\MASM32\>ML the_untidy_code.asm
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.

Assembling: the_untidy_code.asm
the_untidy_code.asm(9) : warning A4011: multiple .MODEL directives found : .MODEL ignored
*sound of belch*


jj2007


Gunther

Jochen,

Quote from: jj2007 on August 15, 2013, 06:17:32 PM
Post the sources, Alex :biggrin:

he will, he will. Please be patient.  :lol:

Gunther
You have to know the facts before you can distort them.

jj2007

Update 18 August concerns only MasmBasic's default editor, RichMasm (located in \Masm32\RichMasm\RichMasm.exe after installation):

include \masm32\MasmBasic\MasmBasic.inc        ; download
        Init
;       if RichMasm finds at least one int 3 that is not commented out, the editor
;       will launch \Masm32\OllyDbg\ollydbg.exe for the current exe with arguments
        int 3        ; Hit F9 in Olly, it will stop here
        Print "The commandline args are [", CL$(1), "] and [", CL$(2), "]"
        Exit
end start

RichMasm options for seeing symbols in Olly:
OPT_Assembler   JWasm         ; download - must be present in \bin (ML 6.15 works, too)
OPT_DebugA      /Zi           ; activate symbols
OPT_Linker      link          ; Masm32 standard, i.e. version 6.14, must be present in \bin
OPT_DebugL      /debug        ; for debugging
OPT_Arg1        "Hello coder"
OPT_Arg2        "what's cooking in the Masm32 forum?"


Note that Olly must be present as \Masm32\OllyDbg\ollydbg.exe

When Olly starts a console app, the console window will be in the foreground. This is rarely what you want, therefore RichMasm has now learned to move Olly to the foreground, so that you can directly hit F9 without having to click the bl**dy console away.

jj2007

#85
Since the zipped package was very close to the Forum's 512k limit, I wrote an installer which pushed it down to 322k. Feedback sought regarding
- the EULA
- the extraction process
- whatever observation you may have 8)

Just open the attachment and double-click on MbSetup.exe
(It's not MSI, sorry, but it seems to do the job, too - source will be available soon)

P.S.: Second version posted, the first one didn't find the image for the title bar :(
P.S.: Third version attached, #2 tried to sell VB to Dave, and I hope that is fixed for the time being ;-)

P.S.: See reply #100 for version #4

dedndave

oops - lol
it says MasmBasic is not for me, then googles VB for me   :lol:
nothing cryptic about that message

i have some of my masm32 subfolders named a little differently
perhaps you could tell us which subfolders must be in place before throwing us to the wolves   :biggrin:

great idea, though
i always wondered if i had it set up correctly, before

jj2007

Quote from: dedndave on August 23, 2013, 01:08:23 PM
oops - lol
it says MasmBasic is not for me, then googles VB for me   :lol:

Soooorry... that means I have to revise the routine that checks if user X is a valid member of the Masm32 community :redface:

What I did is check the registry for the asm_auto_file editor. If there is \Masm32\ in one of the possible entries, you are a good user. Which means you are a bad user, Dave :eusa_naughty:

  call IsMasm32        ; check if user has Masm32 installed
  .if eax
        inc GoodUser
        wLet Button1$="Accept && Install"
        wLet Static$="MasmBasic will be installed to "+wChr$(M32$)+"MasmBasic"
  .else
        wLet Button1$="Continue"        ; will open Google ;-)
        wLet Static$="Bye..."
  .endif

IsMasm32:
        ; If an entry exists in both HKLM\SOFTWARE\Classes and HKEY_CURRENT_USER\SOFTWARE\Classes,
        ; then the value of the entry in HKEY_CURRENT_USER\SOFTWARE\Classes takes precedence (MSDN).
        ; Win7: HKCU & HKCR
        Let edi=GetRegVal("HKCU\SOFTWARE\Classes\asm_auto_file\shell\open\command", 0, "No luck in HKCU...")
        .if !Instr_(edi, "\Masm32\", 1)
                Let edi=GetRegVal("HKLM\SOFTWARE\Classes\asm_auto_file\shell\open\command", 0, "No luck in HKLM...")
        .endif
        .if !Instr_(edi, "\Masm32\", 1)
                Let edi=GetRegVal("HKCR\asm_auto_file\shell\open\command", 0, "No luck in HKCR...")
        .endif
        .if !Instr_(edi, "\Masm32\", 1)
                FileWrite "tmp.asm", "MasmBasic is great"
                lea edi, TmpPath$
                invoke FindExecutable, esi, Chr$("\"), edi
                Kill esi
        .endif
        Clr$ esi
        push Instr_(edi, "\Masm32\", 1)
        .if eax
                or ecx, -1
                .Repeat
                        inc ecx
                .Until byte ptr [edi+ecx]>="A"
                sub edx, ecx
                lea eax, [edi+ecx]
                Let M32$=Left$(eax, edx+7)
        .endif       
        pop eax
        retn
end start

Antariy

Quote from: jj2007 on August 23, 2013, 09:07:14 AM
Since the zipped package was very close to the Forum's 512k limit, I wrote an installer which pushed it down to 322k. Feedback sought regarding
- the EULA
- the extraction process
- whatever observation you may have 8)

Just open the attachment and double-click on MbSetup.exe
(It's not MSI, sorry, but it seems to do the job, too - source will be available soon)

P.S.: Second version posted, the first one didn't find the image for the title bar :(

Just downloaded it, Jochen :t
As for MSI - no need in excuses - don't like MSI packages :biggrin:

As for search for "asm_auto_file", the robust way is to get in HKCR\.asm key the default value contents - if it's empty, then search for the "Shell\Open\command" subkey in the same key, otherwise it will be the name of the key with right "Shell\Open\command". HKCR\.asm default value usually contains redirection to "asm_auto_file", so right redirection path is HKCR\asm_auto_file, but the redirection may be other - depends on different things and how user setup the handling of files, like the opening program.

Antariy

Version 3 works for me, Jochen :t It founds MASM32 package path properly.