Author Topic: MasmBasic  (Read 144157 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Bug warning
« Reply #180 on: April 22, 2014, 08:24:45 PM »
ArrayMerge had a problem with differently sized arrays. It is fixed in version 22 April 2014.

The code below will now work correctly.

include \masm32\MasmBasic\MasmBasic.inc
  Init                  ; ## merge two string arrays ##
  Dim Dest$()
  Dim Src$()
  xor ecx, ecx
  .Repeat
      .if ecx<3
            Let Dest$(ecx)=Str$("Destination #%i", ecx)
      .endif
      Let Src$(ecx)=Str$("Source #%i", ecx)
      inc ecx
  .Until ecx>=10
  ArrayMerge Dest$(), Src$()
  push Dest$(?)      ; put the new element counter on the stack
  xor ecx, ecx
  .Repeat
      Print Str$("\n#%i\t", ecx), Dest$(ecx)      ; see dest 0...2, then source 0...9
      inc ecx
  .Until ecx>=stack
  pop eax
  Exit
end start


Output:
#0      Destination #0
#1      Destination #1
#2      Destination #2
#3      Source #0
#4      Source #1
...
#12      Source #9

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
ArraySet
« Reply #181 on: April 25, 2014, 09:26:18 AM »
Version 25 April supports ArraySet for strings and numerical arrays.
Excerpt from MbSnippets.asc:

include \masm32\MasmBasic\MasmBasic.inc
  Init                 
  PrintLine "ArraySet strings:"
  ArraySet My$() = "These", "are", "four", "strings"
  Let My$(My$(?))="Only strings support"      ; My$(?) is the current number
  Let My$(My$(?))="dynamic expansion"         ; of elements in the array
  For_ ecx=0 To My$(?)-1
      PrintLine Str$(ecx), Tb$, My$(ecx)
  Next

  PrintLine CrLf$, "Same with numerical arrays:"  ; could be DWORD, REAL4, REAL8
  Dim MyNum(5) As DWORD      ; create an array with 6 elements (0 .. 5)
  ArraySet MyNum() = 11, 22, 33, 44, 55, 66      ; assign values
  xor ecx, ecx
  .Repeat
      Print Str$(MyNum(ecx)), Spc2$
      inc ecx
  .Until ecx>=MyNum(?)
  Exit
end start

Output:

ArraySet strings:
0       These
1       are
2       four
3       strings
4       Only strings support
5       dynamic expansion

Same with numerical arrays:
11  22  33  44  55  66

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Bugfix
« Reply #182 on: May 31, 2014, 09:26:45 AM »
Version 31 May 2014 (download) fixes an odd bug: I had built the tinf.lib used for the new UnzipFile function with /subsystem:CONSOLE, so all code using tinf had a console window, including the spreadsheet viewer.

The new UnzipFile decompresses zipped files to a buffer; more in \Masm32\MasmBasic\MbGuide.rtf

Check also the improved QSort function; it allows now to sort string matrices by column, as demonstrated in the spreadsheet viewer.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #183 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Bugfix
« Reply #184 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: 996
Re: MasmBasic
« Reply #185 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #186 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
SetGlobals
« Reply #187 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: 826
  • Assembly is a state of art.
    • RosAsm
Re: MasmBasic
« Reply #188 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #189 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: 826
  • Assembly is a state of art.
    • RosAsm
Re: MasmBasic
« Reply #190 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #191 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Find duplicate files on disk
« Reply #192 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: 3515
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #193 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: 7558
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #194 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