Author Topic: MasmBasic  (Read 217506 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #180 on: June 05, 2014, 09:02:04 AM »
Update 5 June (download) - the unzipper is now even simpler to use:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  UnzipInit "\Masm32\MasmBasic\Res\UnicodeTest.zip"
  ; now restore the first file, and don't forget the timestamp
  FileWrite Files$(0), UnzipFile(0), GfLastWrite(0)
  UnzipExit      ; cleanup
  Exit
end start


It handles Unicode file names, and you can retrieve the optional comment, too.
Full example here.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Bugfix
« Reply #181 on: June 19, 2014, 06:26:00 PM »
Tonight's version of MasmBasic had a little bug in the deb macro:

include \masm32\MasmBasic\MasmBasic.inc     
  Init
  MovVal f:xmm1, "12345678901234567890"
  deb 1, "Result", f:xmm1
  Exit
end start


You have the latest version with the bugfix if the box displays
Result     f:xmm1          1.234567890123457e+19

If you see any other number, download the latest version here.

For latest additions, see True Unicode in the Campus.

sinsi

  • Member
  • *****
  • Posts: 1089
Re: MasmBasic
« Reply #182 on: June 19, 2014, 06:48:45 PM »
Downloaded and installed a version 12 hours ago, all OK.
Saw the new version, downloaded and installed OK until the very end showing RichMasm

Faulting application name: RichMasm.exe, version: 0.0.0.0, time stamp: 0x53a20f44
Faulting module name: RichMasm.exe, version: 0.0.0.0, time stamp: 0x53a20f44
Exception code: 0xc0000005
Fault offset: 0x0000ff0c
Faulting process ID: 0x1940
Faulting application start time: 0x01cf8b99d380e62d
Faulting application path: C:\Masm32\MasmBasic\RichMasm.exe
Faulting module path: C:\Masm32\MasmBasic\RichMasm.exe
Report ID: 130f4421-f78d-11e3-bfda-bc5ff496160b
Faulting package full name:
Faulting package-relative application ID:

I can walk on water but stagger on beer.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #183 on: June 19, 2014, 10:28:57 PM »
Thanks for the feedback, Sinsi. If the offset means "from entry", then it is pcmpeqb xmm0, xmmword ptr [edx] in MbStrLen. So a nullpointer was passed ::)

I always wonder what a len() routine should return if a nullpointer is passed. Zero maybe? Minus one??

Which Windows version was that? Anybody else having the same problem?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
SetGlobals
« Reply #184 on: July 02, 2014, 08:27:42 AM »
The SetGlobals macro allows now to initialise DWORD, WORD, REAL4, REAL8 and string variables in the declaration:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals v1=123456789, MyFile$="SomeTest.txt", v2
  SetGlobals MyR4:REAL4=123456.789012345678, MyR8:double=123456.789012345678
  SetGlobals v3:WORD=12345, v4

  Init
  SetGlobals            ; no args = load ebx, initialise variables
  Print "MyFile$=", MyFile$, CrLf$
  Print Str$("V1=%i", v1), Str$(", v3=%i\n", v3)
  Print Str$("R4=%If\n", MyR4)
  Print Str$("R8=%If\n", MyR8)
  Exit
end start

String variables must have the '$' suffix. In the first call of the .code section (i.e. the line below Init), SetGlobals without arguments initialises these variables.

EDIT: Update 3 July fixed a very odd bug: Recall, when reading an ANSI file that had Unicode embedded, had extremely long strings containing the Unicode parts; that may happen if you saved an inc file as Unicode, and afterwards you create e.g. with copy *.inc AllIncludes.txt a file that will have, oops, an embedded Unicode part. The BadLines variable can be used to test this:

include \masm32\MasmBasic\MasmBasic.inc      ; download
      Init
      Recall "\Masm32\include\AllIncludes.txt", L$()
      ExternDef BadLines:DWORD
      Print Str$("%i lines, of which ", eax), Str$("%i badly formatted", BadLines)
      Exit
end start


In the new version, the array will simply contain Unicode strings where Recall found them; no more obscure crashes, but still, garbage in, garbage out...
Note that Recall has no problems with regular Unicode files - it returns the string array in UTF-8 format (and you can use wRec$(My$(123)) if you need UTF-16, e.g. for menus).
« Last Edit: July 27, 2014, 09:10:04 PM by jj2007 »

guga

  • Member
  • ****
  • Posts: 848
  • Assembly is a state of art.
    • RosAsm
Re: MasmBasic
« Reply #185 on: August 02, 2014, 10:27:19 AM »
Hi JJ

not sure if you are aware of this small bug on masmbasic, but with winXP SP3, the menus text are being detached when you resize the window.

To see the error, you need to open masmbasic and then press the mouse upon a windows and drag it vertically.
1st - Double click the window to you be able to drag it
2nd one the window is not maximixed, click on the title bar with the left button pressed and drag the window

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

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #186 on: August 02, 2014, 04:29:47 PM »
Hi Gustavo,

It's a feature, not a bug ;-)

On my machines (Win XP, W7-32, 2*W7-64) it works, though. The menus get detached while dragging or resizing but follow some milliseconds later. Strange that for you it's different.

The background for this strange feature is

a) Aero (not allowing drawing directly on the caption) and

b) the fact that assembly is a "vertical" language, with one short instruction per line: I didn't want to sacrifice a line for a stupid standard menu.

Besides, the menu activates itself without clicking, like most browser menus nowadays.

Still, I am curious why the menu stays put in the middle of the desktop in your case... ::)

guga

  • Member
  • ****
  • Posts: 848
  • Assembly is a state of art.
    • RosAsm
Re: MasmBasic
« Reply #187 on: August 02, 2014, 06:57:41 PM »
A feature ? Hmm..interesting...I never used aero before to see what exactly it is.

But...since this is the normal behavior, son´t worry...the menus on the middle of the desktop goes back to the original position after a few time (milliseconds, in fact)....I took the screenshot pressing "PrintScreen" thinking it was a bug to show you, because i didn´t found other way to explain.

But...do aero works on XP ? I would like to see what is this feature. It is unusual, but, interesting.
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

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #188 on: August 02, 2014, 08:15:16 PM »
No aero on XP. It was introduced with Vista, but it seems not very popular. Most people I know reverted to the classic non-aero themes. Don't even know if it still exists on Win8.

BTW the editor is not needed to assemble MasmBasic code, but it has some nice features. For example, load a big source (>10,000 lines), select a global variable like "buffer" and hit F3...

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Find duplicate files on disk
« Reply #189 on: August 18, 2014, 07:27:55 AM »
Just for fun, a 40 lines app to find duplicate files, starting from the current folder:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Let esi=CurDir$()+"*.*"
  .While 1
      Let esi=Input$("\nEscape+Return to quit\nEnter path & wildcards:\t", esi)      ; e.g. C:\Masm32\*.*
      .Break .if !Len(esi)            ; user pressed Escape
      .if !Instr_(esi, "*")
            PrintLine "Unrestricted search not allowed"
      .else
            GetFiles esi
            .if eax
                  push eax
                  Print Str$("%i files found\n\n", eax)
                  xor ecx, ecx
                  .Repeat
                        mov edi, Files$(ecx)
                        mov ebx, Rinstr(edi, "\")            ; let's move the name part to the front for sorting
                        .if ebx
                            Let Files$(ecx)=Mid$(edi, ebx+1)+Tb$+GfDate$(ecx)+Spc2$+GfTime$(ecx)+Spc2$+Str$(GfSize(ecx))+Spc2$+Left$(edi, ebx)
                        .endif
                        inc ecx
                  .Until ecx>=stack
                  SortFiles name, asc            ; sort by name, ascending
                  xor ecx, ecx
                  Let ebx="#"            ; no such file
                  .Repeat
                        mov edi, Files$(ecx)
                        .if Instr_(ebx, Left$(edi, Instr_(edi, Tb$)), 1)==1
                            PrintLine CrLf$, edi, CrLf$, ebx
                        .endif
                        Let ebx=Files$(ecx)
                        inc ecx
                  .Until ecx>=stack
                  pop eax
            .endif
      .endif
  .Endw
  Print "bye"
  Exit
end start

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #190 on: August 19, 2014, 05:17:02 AM »
Jochen,

nice little application. I've no redundancy on my machine.  :lol:

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #191 on: August 20, 2014, 08:01:33 AM »
nice little application. I've no redundancy on my machine.  :lol:

Thanks, Gunther.

Update 20 August (here):

- GfSetInfo allows to copy a file's timestamp and size to another element of the Files$() array generated by GetFiles, or time & size of the last match of Exist(); example:

GfSetInfo 1, GfLastWrite(-1)      ; set Files$(1) to Exist() time and size
Destination is an element of Files$(), source is either Files$ (index 0 ... n) or the last match of Exist() with index -1.

- wChr$() can now have embedded zeros:
mov esi, wChr$("All files", 0, "*.*", 0)

This allows to avoid a bug in LoadStringW when loading a resource string with trailing zeros..

- the menus of RichMasm are now better aligned, see Pelles C

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
WM_DROPFILES handler
« Reply #192 on: August 25, 2014, 09:23:14 AM »
  CASE WM_DROPFILES
            GetFiles WM_DROPFILES      ; put dropped files into the Files$() array
            push eax
            Let esi=Str$("%i files and folders dropped:", eax)
            xor ecx, ecx
            .Repeat
                  void Rinstr(Files$(ecx), "\")      ; strip the path: Rinstr() returns absolute pos in eax (and relative pos in edx)
                  lea edi, [eax+1]
                  Let esi=esi+Str$("\n%i\t", GfSize(ecx))+GfDate$(ecx)+Spc2$+GfTime$(ecx)+Tb$+edi      ; size, date, time and filename
                  inc ecx
            .Until ecx>=stack
            pop eax
            SetWin$ hEdit=esi                 


Sample output:
7 files and folders dropped:
0       13.01.2012  19:59:15   procs
0       13.01.2012  19:59:14   tutorial
0       13.01.2012  19:59:14   tools
65536   17.08.2014  15:04:04   uniedit.exe
5598    17.08.2014  04:13:03   AllFiles.zip
22528   17.08.2014  00:40:24   topgun.exe
37376   17.08.2014  00:25:44   qeditor.exe


Full source attached, requires MasmBasic of 25 August 2014.

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #193 on: August 26, 2014, 02:08:24 AM »
Good idea, Jochen. Thanks.  :t

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8889
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic bug fixes
« Reply #194 on: September 22, 2014, 08:05:55 AM »
Version 22 Sept 14 (download):

- BUGFIX: Val("12.34.56") returns now correctly 12.34
- BUGFIX: StringsDiffer used wrong location to test the case-insensitive flag

- New feature: Now dialogs close apart from IDOK and IDCANCEL also for IDs 100...120, and return the ID

« Last Edit: September 22, 2014, 09:26:51 PM by jj2007 »