News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

MasmBasic

Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic

jj2007

Hi Ian,

RichMasm.exe is the editor, and I use it all the time on several machines. It is clean, no virus there, I know it because I build it from the source, over 20,000 lines. However, several AV scanners report malware, see the VirusTotal results: 18 out of 70! Here is the report for the same file but uncompressed, and the detection rate drops to 6 of 69. So simple compression is sufficient for 12 of these brilliant AV engines to shout foul. The reason is that no AV can test for all viruses and trojans in the wild, the databases would be huge, and testing would slow down your Windows to a crawl. So they use "heuristics" for detecting "suspicious behaviour", such as: Does the instruction "pushad" appear in the exe? Normal for assembler, almost never used by C compilers.

Check what the better AV engines report, like Kaspersky, Symantec etc., and then decide whether you really want to learn assembly. Once your executables grow a bit in size, they will never look like mainstream C/C++ executables - bad luck :P

I see you are using Avast. Virustotal says Avast reports Win32:Evo-gen, and googling for that virus leads quickly to
Is Win32.Evo-gen(Susp) a False Positive? and What's with all the new Win32:Evo-gen [Susp] false positives?  (Read 23100 times), so RichMasm.exe is not the only victim of Avast.

If you are interested, the forum has a dedicated section "AV Software sh*t list".

Cheers, Jochen

P.S.: VirusTotal has "Details" and "Behaviour" tabs. Here are details for the attached uncompressed RichMasm.exe:
Win32 Executable MS Visual C++ 4.x (59.6%)
Win32 Executable MS Visual C++ (generic) (13.8%)
Win64 Executable (generic) (12.2%)
Windows screen saver (5.8%)
Win32 Dynamic Link Library (generic) (2.9%)


So they believe with 59.6+13.8%=73.4% probability that it was built with MS Visual Crap :icon_mrgreen:

Here is another example, it is the Download URL with UTF8 executable:
Win64 Executable (generic) (47.7%)
Windows screen saver (22.6%)
Win32 Dynamic Link Library (generic) (11.3%)
Win32 Executable (generic) (7.7%)
OS/2 Executable (generic) (3.5%)


So they believe it's a Win64 exe. Or a DLL, or maybe a screensaver. Oh well, this is hitech, folks :t

I attach the uncompressed version of RichMasm.exe - welcome to the Forum :icon14:

felipe

nice info  :icon14:

jj2007

Please reinstall MasmBasic, updated on 25 January 2019.

Minor improvements under the hood, plus:

1. A new macro, _Local; my old favourite programming language, GfaBasic, had local variables (of course), but in contrast to MASM one could initialise them. This is now possible in Assembler:

include \masm32\MasmBasic\MasmBasic.inc         ; download
.code

MyTest proc uses esi edi ebx arg1, arg2
LOCAL var1, var2, rc:RECT, buffer[100]:BYTE                   ; "normal" locals, will be initialised to zero
_Local MyR4:REAL4=12345.6789, MyR8:REAL8=1234567890.1234567890         ; REAL variables
_Local var3=arg2, var4=200, x$=arg1, y$="Hello World"                  ; DWORDs and strings
  ClearLocals                          ; clear or set locals
  Print Str$("v1=%i", var1), Str$(", v2=%i", var2), Str$(", v3=%i", var3), Str$(", v4=%i", var4), Str$(", a2=%i", arg2)
  Print Str$(", R4=%7f", MyR4), Str$(", R8=%Df", MyR8)
  PrintLine ", x$=", x$, ", y$=", y$
  ret
MyTest endp

  Init
  For_ ecx=0 To 150
        invoke MyTest, Str$(ecx), ecx
  Next
EndOfCode


The syntax is _Local var=whatever (i.e. understroke plus camel case Local). The declarations must be followed by ClearLocals. Full project is attached.

2. NoTag$() recognises many more special characters now. Test it:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Let esi=FileRead$("http://masm32.com/board/index.php?topic=94.0")     ; assign page to a string
  FileWrite "temp.txt", NoTag$(esi)     ; strip the tags and write plain text to disk
  ShEx "temp.txt"               ; have a look with ShellExecute
EndOfCode


3. A bugfix for the SysLink GuiControl; the tooltips didn't appear. Now it's working fine, see attached project and screenshot below.

anunitu

as always JJ love your hard work on masmbasic

jj2007

Thanks, anunitu :icon14:

anunitu


jj2007

Update 31 January 2019:
- Rand(): randomness of REAL8 variables improved
- add2m and sub2m macros (use like m2m)
- MakePath: graphs can now be modified 'on the fly', e.g. in the Timer event, thus allowing moving shapes (demo attached):

  MakePen hPenBez, RgbCol(255, 255, 0, 0), width 4
  ArraySet pts() As DWORD = 10, 10, 80, 40, 40, 190, 190, 50, 100, 170, 180, 170, 100, 0
  MakePath 123, Bezier(pts())

Event Timer
  add2m pts(2), dirX
  add2m pts(7), dirY

Event Paint
  GuiDraw 123, hPenBez, 10.0, 10.0, 2500, 5000  ; x, y, scaleX, scaleY

jj2007

The MasmBasic update of 5 February 2019 features a new ArrayIndex() macro inspired by Guga's Fast Compare Real8 with SSE thread. The macro returns in eax the position of a number in a sorted array; if dl is zero, an exact match was found, otherwise the nearest position will be returned in eax. Syntax example:

Print Str$("The position of the number 8377 in the array table() is %i", ArrayIndex(table(), 83777))

The sorted array, table() in this example, can be composed of DWORD, QWORD or REAL8 values. Below and attached a complete example:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  StringToArray FileRead$(99), table() As DWORD  ; read an array from resource #99
  ArraySort table()    ; sort ascending
  Let esi="83777"      ; just a suggestion
  Print "Hit Escape & Return to exit"
  .While 1
        Print At(0, 1)
        Let esi=Input$("Gimme a prime: ", esi)
        .Break .if !Len(esi)
       void ArrayIndex(table(), Val(esi))      ; works with DWORD, QWORD and REAL8 arrays
        .if dl
                PrintLine esi, Str$(" is not a prime, sorry!!!! - the nearest prime is %i   ", table(eax))
        .else
                PrintLine Str$("congrats, prime found at pos #%i !!", eax), Space$(32)
        .endif
  .Endw
EndOfCode

guga

Tks, JJ :)

Found only a small issue. Whenever the searching number is bigger or equal to the last one on the table it should return the last one and not 2 before.

For example, i gave a try with only 10 numbers to search:
Table =  101, 103, 107, 109, 113, 127, 131, 137, 139, 149
(So, the Index/Pos = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

Number is smaller or equal to the 1st one is ok :t Ex:
Number to Search = 100. Return nearest number is 101. (So, index = 0)  OK !! :t
Number to Search = 101. Return nearest number is 101. (So, index = 0)  OK !! :t

Numbers in between are Ok :t
Number to Search = 104. Return nearest number is 103. (So, index = 1)  OK !! :t


Number is equal,is ok only when it is not the last one. Ex:
Number to Search = 103. Return index = 1  OK !! :t
Number to Search = 139. Return index = 8  OK !! :t
But....
Number to Search = 149. Not found. Return index should be 9.


but...when Number is bigger or equal to the last, it is returning 2 positions backwards and not the last one

Number to Search = 149. Not finding the proper number. Is giving a message of nearest The correct should be 149. So, index (Pos from 0 to XX) = 9
Number to Search = 150. Return nearest number is 139. The correct should be 149. So, index (Pos from 0 to XX) = 9
Number to Search = 151. Return nearest number is 139. The correct should be 149 So, index = 9
Number to Search = 2751. Return nearest number is 139. The correct should be 149 So, index = 9
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

guga

Btw. the same issue i described happens when the size of the table is odd. For example , table size = 11
Table =  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 177
(So, the Index/Pos = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

Number to search = 149; Found at pos 8 (139) rather then 9

It cannot find the number and, this time (For odd sized table), is returning 3 positions backwards, rather then 2 when the same error happens for even sized table.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

Thanks a lot, Guga. I'm working on it...

guga

You´re welcome, JJ  :t :t :t

Thank you for the effort. This function will be very helpful for the CieLCH functions i´m making. I´m still working on the pdf i told. I finished part of it, but still trying to find the limits of all those equations. For what i saw so far, those equations are utterly incorrect, since they allows the user to input any RGB value despite the fact that some of those combination simply don´t matches to the results of their own formulas. The major problem is find a way to make them work ok, without using incorrect RGB values whose combinations, simply were impossible on the CieLab/CieLCH color spaces. This is the main reason why the backwards convertion allows clipping and generate incorrect results.

For example, when the user inputs a RGB value originate form a HSL convertion it is not guaranteed that it will result the proper Lab or LCH values from the perceptual colorspaces, since the input can be a combination of colors that don´t actually "exists".
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

Update 8 February 2019:
- ArrayIndex(someArray(), findnumber) is now working properly
- three new macros Log2, LogE, Log10:

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals REAL10 ct, tmp10
  Init
  For_ ct=1.5 To 10.0 Step 0.5
        Print Str$(" Log2(%2f)", ct), Str$("\t%Jf ", Log2(ct)v), Str$("\t%Jf ", LogE(ct)v), Str$("\t%Jf\n", Log10(ct)v)
  Next
  void Log10(123.4567890)
  fadd FP4(3.0)
  ExpXY(10.0, ST(0), tmp10)     ; calculates 10^ST(0) and saves it to tmp10
  Inkey Str$("The value of tmp10 is now %f", tmp10)
EndOfCode


Output:
 Log2(1.5)      0.5849625007211561815   0.4054651081081643820   0.1760912590556812421
Log2(2.0)      1.000000000000000000    0.6931471805599453094   0.3010299956639811952
...
Log2(9.5)      3.247927513443585494    2.251291798606495151    0.9777236052888477664
Log2(10.0)     3.321928094887362348    2.302585092994045684    1.000000000000000000
The value of tmp10 is now 123456.8

jj2007

Update 12 February 2019 fixes a minor glitch in the editor. As a side effect, a request by HSE to set the foreground colour has been answered: YES it works now.

The snippets collection (\Masm32\MasmBasic\Res\MbSnippets.asc) has one problem with the ArraySet examples:

  Dim MyNum(5) As DWORD         ; create an array with 6 elements (0 .. 5)
  ArraySet MyNum() = 11, 22, 33, 44, 55, 66    ; assign values


This syntax is obsolete and crashes, unfortunately. The proper way to handle this is like this:

  ArraySet MyNum() As DWORD = 11, 22, 33, 44, 55, 66    ; create an array and assign values
  xor ecx, ecx
  .Repeat
        mov MyNum(ecx), Rand(12345)
        PrintLine Str$(ecx), Tb$, Str$(MyNum(ecx))
        inc ecx
  .Until ecx>=MyNum(?)


First, a DWORD array gets created, and 6 values are being assigned.
The loop replaces these values with random ones (range 0... 12344) and prints them.

Note a tricky little detail: .Until ecx>=MyNum(?) exits the loop when the current number of elements is reached. Take the = away, and you'll get an endless loop because when assigning a value to the last element+1, the array gets automatically expanded. This is not a bug, it's a feature of dynamic arrays.

jj2007

Update 2 April '19 adds a bunch of improvements under the hood, check this Gui programming post for an example. Inter alia, the new CanvasZoom macro allows to "zoom" a control:

GuiControl MyList, "listbox", x800, w200       ; put the box at x=80% width, full height
GuiControl MyImg, "canvas", w800, h500         ; images have width 80%, height 50%
GuiControl MyMap, "canvas", y500, h500, w800   ; same but at y=50% of height

...
Event Key
  Switch_ VKey                                 ; press M or I to zoom a canvas control (press twice to toggle)
  Case_ VK_I:  CanvasZoom MyImg, MyList        ; zoom the image, hide the listbox
  Case_ VK_M:  CanvasZoom MyMap, MyList        ; zoom the map, hide the listbox
  Endsw_


Attached an image viewer; extract the exe to a folder that contains images (jpg, png, animated gif), then run the exe.