Author Topic: MasmBasic  (Read 439441 times)

frktons

  • Member
  • ****
  • Posts: 512
Re: MasmBasic - a fast and easy-to-use library
« Reply #15 on: November 25, 2012, 03:21:08 AM »
Hi jj.

MasmBasic is really a nice project. If I had enough knowledge I'd started
a similar project myself. Unfortunately I'm not able to do much with it for the time
being.

It remains, however, one of my goal to learn and use some MasmBasic as soon
as I've enough capacity to do it.

Carry on this optimal work.

Frank
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #16 on: December 03, 2012, 10:43:42 AM »
Thanks a lot, Frank.

Version 3 December features an improved xHelp, now included in the MasmBasic package.
Inter alia, xHelp has learned how to add F1 context-sensitive help to qEditor. After extraction of the package (the archive in post #1 of this thread) with "use folder names", launch \Masm32\InstallXhelp.exe. Afterwards, you can select some text, e.g. CreateWindowEx in qEditor, and press F1. Compliments to Hutch who made such a great plugin interface for the Masm32 editor :t

And apologies that I stole the idea to create a plugin interface for RichMasm, too - PM me for details ;-)

frktons

  • Member
  • ****
  • Posts: 512
Re: MasmBasic - a fast and easy-to-use library
« Reply #17 on: December 05, 2012, 01:25:15 AM »
One lesson a day keeps the teacher away [somehow]  :lol:

The only thing I really miss for an extension of MASM32 like
MasmBasic is a tutorial to learn step by step the use of the
MACROS library and routines.

Probably some help can be found in the editor and in the
examples, but a Tutorial is always welcome.  :t
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #18 on: December 26, 2012, 10:00:02 AM »
Changes in the update of 26.12.2012 (attached to first post, details in \Masm32\MasmBasic\MbGuide.rtf):

AddWin$
        AddWin$ hEdit=CrLf$+"[one line more]"        ; append some text to an edit control
        ; this line appends the current date and time to an edit control:
        AddWin$ hEdit=CrLf$+"["+Trim$(Launch$("cmd.exe /C date /T"))+", "+Trim$(Launch$("cmd.exe /C time /T"))+"]"

WritePipe
        Launch "cmd.exe /C time", SW_RESTORE, cb:hEdit        ; launch an app that requires console input; show its output in the edit control
        WritePipe "20:40:50"                        ; set the time
        ; you may add a 0 as second argument if you don't want a CrLf sequence to be appended:
        WritePipe esi, 0        ; write zero-delimited string in esi, do not append CrLf
Rem        will show an error message if the pipe was closed for some reason

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: MasmBasic - a fast and easy-to-use library
« Reply #19 on: January 03, 2013, 12:00:20 AM »
Jochen,

it seems you've done a great effort for the new update. Did you burn the midnight oil?

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

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #20 on: January 03, 2013, 02:23:28 AM »
it seems you've done a great effort for the new update. Did you burn the midnight oil?

Yes I did, Gunther - but I just fixed a "midnight bug". Launch$() returns output from a console proggie, but it is not designed for proggies that expect input, and it choked badly when I tried. Version 2 Jan b behaves better, it just returns La$? to indicate an error.
----
Changes in the update of 2 Jan 2013 concern the handling of pipes in Launch (more in \masm32\MasmBasic\MbGuide.rtf):

        dec ready2load                ; set the "we launched a process" flag
        Launch esi, SW_MINIMIZE, cb:hOutput  ; cb: = we want to see the output

...

        CASE WM_TIMER
                .if ready2load        ; flag "we launched a process"
                        .if ExitCode()!=STILL_ACTIVE        ; process finished?
                                and ready2load, 0        ; clear the flag and
                                call LvGetFiles        ; load the processed files
                        .endif
                .endif


Basically, you can thus:
- launch an external preprocessor
- watch its output in an edit window
- and proceed once the external process is no longer STILL_ACTIVE.

It is now also possible to have a permanent pipe, e.g. with cmd.exe, and to retrieve output from other processes with Launch$() in parallel.

anta40

  • Member
  • ***
  • Posts: 315
Re: MasmBasic - a fast and easy-to-use library
« Reply #21 on: January 08, 2013, 02:10:34 PM »
Hi jj,

This code compiles fine and works as expected (with the latest MasmBasic)
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc

.data?
aNumber dd ?

Init
MovVal aNumber,Input$("Input: ")
add aNumber, 123
Print "Result: ",Str$(aNumber)
Exit
end start

But if you shorten the input message like this:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc

.data?
aNumber dd ?

Init
MovVal aNumber,Input$("N: ")
add aNumber, 123
Print "Result: ",Str$(aNumber)
Exit
end start

Then the result is compilation error

Quote
JWasm v2.10pre, Dec 30 2012, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

input.asm(7) : Error A2172: Initializer magnitude too large:
 repargA(55)[MasmBasic.inc]: Macro called from
  cStyle$(99)[MasmBasic.inc]: Macro called from
   Input$(3)[MasmBasic.inc]: Macro called from
    input.asm(7): Main line code
input.asm: 11 lines, 1 passes, 78 ms, 0 warnings, 1 errors

Is this a bug?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Always trouble with four-letter words...
« Reply #22 on: January 08, 2013, 05:41:01 PM »
Is this a bug?

YES, fat and ugly (but harmless). Will be fixed asap, thanks for the feedback :t

The reason is that "abcd" is an immediate for the macro engine, not a string. For example, you can write mov eax, "abcd" or mov al, "x". But the macro can check for the <"> and then decide to treat it as a string. The bug didn't show up until now because all my test examples had more then four chars - and then JWasm & Ml are clever enough to realise "no, can't fit into 32 bits, so it must be a string". Cute, ain't it?  ;)

anta40

  • Member
  • ***
  • Posts: 315
Re: MasmBasic - a fast and easy-to-use library
« Reply #23 on: January 08, 2013, 06:05:52 PM »
Ah I see.
Indeed it's not harmful, just a little annoying.
I was confused for a while why my code wouldn't compile, until somehow I reverted back the input message, and finally the assembler accepted it.

:P

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #24 on: January 08, 2013, 08:18:19 PM »
Until the new version is ready, you can use Chr$() as a workaround:

; MovVal aNumber,Input$("nu: ", "1000")
MovVal aNumber, Input$(Chr$("nu: "), "1000")

jeivarmarr

  • Guest
Re: MasmBasic - a fast and easy-to-use library
« Reply #25 on: January 09, 2013, 07:03:34 AM »
I have this problem  :(
Then the result is compilation error
MasmBasic.inc (5871): error A2102: Symbol not defined: CP_UTF8
MasmBasic.inc (6288): error A2102: Symbol not defined: OFN_ENABLESIZING
MasmBasic.inc (6289): error A2102: Symbol not defined: OFN_ENABLESIZING

some solution?

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #26 on: January 09, 2013, 08:41:34 AM »
both symbols are defined in windows.inc

you are simply not including the proper include files
it is possible that you are trying to assemble a file on a different drive than the one where masm32 is installed

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #27 on: January 09, 2013, 08:46:14 AM »
Dave is correct, they are defined in Windows.inc

How does your source start? There should be no problem if your first line is
include \masm32\MasmBasic\MasmBasic.inc

On top of MasmBasic.inc you find this:
IFNDEF _wininc_
   include   \masm32\include\masm32rt.inc
   .686   ; JWasm needs this
   .xmm
ENDIF


In other words, all standard includes are in anyway.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
MasmBasic - major update
« Reply #28 on: March 02, 2013, 10:34:04 AM »
With 145 downloads, the Jan 2 version got a bit stale, so I guess it's time for an update.

Many improvements "under the hood", but also some visible goodies; inter alia, all arrays (strings, byte/word/dword, REAL4/8/10, structures) can now be dynamically defined, e.g.

        Dim My$()
        Dim NormalDist() As DWORD
        Dim Sinus() As REAL8

Note though, that values can be assigned only incrementally, e.g.

        Dim My$()
        Let My$(99)="Hello"        ; illegal, will throw an error
        xor ecx, ecx
        .Repeat
                Let My$(ecx)=Str$("#%i", ecx)
                inc ecx
        .Until ecx>9999

The deb macro has learned to display flags (without changing them, of course):

        deb 4, "End of loop:", ecx, flags, FLAGS

flags displays carry, zero, sign and overflow, FLAGS the whole set:

End of loop:
ecx             10000
flags:          czso
FLAGS:          cpAzstIdo


c means carry clear, C carry set, etc.

Last but not least, attached a minimally modified \Masm32\examples\exampl01\generic\generic.asm:
1. Includes were replaced by the usual one-liner: include \masm32\MasmBasic\MasmBasic.inc
2. These few lines were added below "end menu commands":

    ;====== end menu commands ======

    .elseif uMsg == WM_CREATE
        ToolTips start        ; we'd like to see the country names
        ToolTips end

        Dim NormalDist() As DWORD        ; read the data of a normal distribution from file
        ArrayRead NormalDist(), "NormalDist.dat"

        ArrayLoadMap 0, "Europe"        ; load a map

        Dim Sinus() As REAL8        ; define an array for a sinus curve
        xor ecx, ecx
        push 180
        fild stack        ; stack is an equate for dword ptr [esp]
        push ecx
        fldpi
        fdivr
        fstp REAL4 PTR stack[4]
        .Repeat
                mov stack, ecx
                fild stack
                fmul REAL4 PTR stack[4]
                fsin
                fstp Sinus(ecx)
                inc ecx
        .Until ecx>500
        pop ecx
        pop eax

    .elseif uMsg == WM_MOUSEMOVE
                ArrayMapRegion(lParam, 0, hWnd)

    .elseif uMsg == WM_PAINT
        ArrayPlot hWnd, RgbCol(200, 255, 240)                ; init with window (or control) handle and background colour
        ArrayPlot 0, RgbCol(200, 200, 200), lines:2        ; plot map 0 as loaded above, with grey border and 2px lines
        ArrayPlot Sinus()        ; plot the sinus curve defined above
        ArrayPlot NormalDist()
        ; ------ here you could add additional features, e.g. a legend ------
        ArrayPlot exit, "Europe"        ; finish with a title

    .elseif uMsg == WM_CLOSE


The output? Check yourself :biggrin:

P.S.: With more recent MasmBasic versions, replace the start: label with Init, otherwise it will crash.
« Last Edit: September 19, 2017, 06:18:37 PM by jj2007 »

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #29 on: March 02, 2013, 10:41:08 AM »
so - what are we looking at, Jochen ???
is it, in any way, related to the pr0n ban in Iceland ?   :redface:
it seems not to have affected pr0n in Western Europe   :P

btw - when i "install" MasmBasic, where are the read-me's that outline how to do that ?