Author Topic: MasmBasic  (Read 152971 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #270 on: September 19, 2015, 05:29:10 PM »
Problem could be an obsolete file association, or that RichMasm.exe and your asm file are on different drives. Try finding ???:\Masm32\MasmBasic\RichMasm.exe, then drag an asm file over the exe.

Version 20 September: Problem fixed. RichMasm will work now even if the source is on a different drive.
« Last Edit: September 20, 2015, 09:55:26 AM by jj2007 »

HSE

  • Member
  • ****
  • Posts: 550
  • <AMD>< 7-32>
Re: MasmBasic
« Reply #271 on: September 20, 2015, 11:52:16 AM »
Perfect now  :t

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #272 on: September 20, 2015, 06:09:25 PM »
Perfect now  :t

In this case, I have a special version of the help file for you :greensml:

HSE

  • Member
  • ****
  • Posts: 550
  • <AMD>< 7-32>
Re: MasmBasic
« Reply #273 on: September 21, 2015, 08:59:36 AM »
Better and better!  Thanks

But I use a lot of text coloring, for assembly programming mostly in RadAsm (a more dark version that the released one) . Of course some pure GreyAndBoring for small tests in QEditor.

Testing MasmBasic, RichMasm is always the first option  :biggrin:.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Fast MemSet and Instr() algos
« Reply #274 on: September 25, 2015, 09:11:53 AM »
Version 25 September 2015 features:

- fast string search:
  .if Instr_(FAST, pBuffer, pPattern, 0)
        Print "substring found"

- fast MemSet:
      MemSet offset somebuffer, 0, 1000                    ; destination, pattern, #bytes
      MemSet offset somebuffer, "x", 1000                  ; 1000 * x
      MemSet offset somebuffer, Mirror$("abcd"), 1000      ; 250 * abcd, slightly faster
      mov eax, Chr$("Masm32 is great ")                    ; string must have (at least) 16 bytes
      movups xmm0, oword ptr [eax]
      mov edx, offset somestring
      MemSet edx, xmm0, 99


The two new commands are on recent CPUs more than twice as fast as their C/C++ equivalents; Instr_() supports also mode 2, i.e. ignore case of the first character (as in "This is OK, this too") without significant speed loss.

TWell

  • Member
  • ****
  • Posts: 748
Re: MasmBasic
« Reply #275 on: September 25, 2015, 04:53:38 PM »
Avast don't like that Setup.exe :(

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #276 on: September 25, 2015, 05:40:49 PM »
Avast dislikes many things, just disable it temporarily. I have no time and no money to sue them for damaging the reputation of the library, but false positives are a fat problem. Did you know that we have even a dedicated sub-forum called AV Software sh*t list?

Attached an updated "MasmBasic for C" example. Extract to a folder named \Masm32\MasmBasic\Mb4C and make sure it's on the same drive as Masm32 and Pelles C (this is clumsy, I know, and will change when I find time to fix it).

dedndave

  • Member
  • *****
  • Posts: 8748
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #277 on: September 26, 2015, 03:15:45 AM »
soooo
should i uninstall an older version first, or will the new one take care of it ?

dedndave

  • Member
  • *****
  • Posts: 8748
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #278 on: September 26, 2015, 03:37:05 AM »
better question here....

how do i do a clean uninstall of MasmBasic?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #279 on: September 26, 2015, 04:13:34 AM »
should i uninstall an older version first, or will the new one take care of it ?
...
how do i do a clean uninstall of MasmBasic?

The installer will just overwrite any MB files, unless they have been altered after the new version. Normally, you can't do anything wrong with this logic; unless you fumble with MasmBasic.inc, and forget to make a backup. But that would be about as stupid as improving Windows.inc and re-installing Masm32 :biggrin:

Re uninstall: It doesn't write anything to the registry, so it's just the \Masm32\MasmBasic folder. The editor has the habit to save user-written code to \Masm32\MasmBasic\AscUser, so you might check if there is anything valuable in there.

Attached a list of all currently installed files.

dedndave

  • Member
  • *****
  • Posts: 8748
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #280 on: September 26, 2015, 04:22:19 AM »
thanks Jochen   :t

it's been a while since i updated it
so, i will delete the folder and install "anew"

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #281 on: September 26, 2015, 04:46:35 AM »

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #282 on: October 01, 2015, 08:52:35 AM »
Version 1 October 15 features the new ultrafast variant of Instr_():

Instr_, Rinstr, wInstr, InstrOr
      Print "The current drive is ", Left$(ThisExe$, Instr_(ThisExe$, "\")-1)
      mov pos, Instr_(1, L$(n), "equ", 1+4)      ; 1=start pos, 1=case-insensitive + 4=full word
Rem   - returns relative pos in edx, absolute in eax
      - if no match is found, zero is returned in edx, and eax points to the start of the 'haystack'; same if 'needle' is empty
      - six syntax variants allowed:
         A: has startpos:      Instr_(1, "Test", "Te", 2)     ; 4 args
         B: no startpos:      Instr_("Test", "Te", 2)         ; 3 args, last one immediate = mode
         C: has startpos:      Instr_(1, "Test", "Te")        ; 3 args, last one not immediate
         D: no startpos:      Instr_("Test", "Te")            ; 2 args
         E: test several patterns:      InstrOr("Test", "Te" or "st", 1)  ; 3 args (startpos is 1)
         F: extra fast mode:      Instr_(FAST, My$(ecx), "Hello", 0)      ; 4 args, no startpos, modes 0+2 only
       - case & mode (bitwise flag):
         0=case-sensitive, +1=insensitive, +2=intellisense (Name=name),
         +4=full word search, +8=include start of line in text block search
         Note: full word search returns failure for chars above ASCII 64 to the left or right
         Example: Nostructfoundhere, this123struct456isfound, this@struct, too

         The FAST option is about twice as fast as CRT strstr, and three times
         as fast when used with string arrays;

         using FAST, binary search in haystacks containing zeros is possible by
         assigning the buffer size to edx:
           mov edx, LastFileSize      ; any info on length of buffer can be used with edx
           Print Str$("Pos in executable: %i", Instr_(FAST, esi, "kernel32", 2 or 64)      ; 2=case-insensitive, 64=len in edx


       - wRinstr is available but only as wRinstr(src, pattern) with a one-byte pattern (e.g. "\")

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Enum$
« Reply #283 on: October 03, 2015, 12:08:29 PM »
MasmBasic version 3 October features Enum$(), the companion to Enum:

Enum            ; create a list of IDs
Enum      IdMenuNew, IdMenuSave, IdMenuCopy, IdTimer
Enum      20:IdEdit, IdButton1, 30:IdButton2, IdStatic, IdFind, IdFindStatic
Remdefault start is 10, but (as shown above) new start values can be specified with nn:

Enum$          ; return numeric constant as text
Case WM_CREATE
  Enum 20:IdEdit, IdButton1, 30:IdButton2, IdStatic, IdFind, IdFindStatic
  ; use with CreateWindowEx
Case WM_COMMAND
  ; ID is loword(wParam), print it as Enum$(ID, list of numeric constants)
  PrintLine "command for control ", Enum$(word ptr wParam, IdEdit, IdButton1, IdButton2, IdStatic, IdFind, IdFindStatic)
  mov ecx, Enum$(uMsg, WM_CREATE, WM_PAINT, WM_SIZE, WM_SIZING, WM_COMMAND)
  .if byte ptr [ecx]!="?"      ; if no matching entry is found, Enum$() returns a question mark
      PrintLine "Message: ", ecx      ; output e.g. Message: WM_PAINT
  .endif


Below and attached a full example showing a practical use of Enum$().

include \masm32\MasmBasic\MasmBasic.inc      ; download
uselib ntdll            ; for RtlGetVersion
  Init                  ; OPT_Assembler JWasm ; ML chokes with version suite string
  sub esp, RTL_OSVERSIONINFOEXW-DWORD
  push RTL_OSVERSIONINFOEXW      ; set size member
  invoke RtlGetVersion, esp
  mov ecx, esp      ; ecx is pointer to RTL_OSVERSIONINFOEXW structure
  ovi equ [ecx.RTL_OSVERSIONINFOEXW]      ; MSDN
  .if eax
      PrintLine "RtlGetVersion failed with ", Err$()
  .else
      PrintLine Str$("RtlGetVersion\t%i.", ovi.dwMajorVersion), Str$(ovi.dwMinorVersion), Str$(" SP %i.", ovi.wServicePackMajor), Str$(ovi.wServicePackMinor), Str$(" build %i", ovi.dwBuildNumber)
      Print "Suite mask", Tb$, Hex$(ovi.wSuiteMask), ": "
      For_ esi=0 To 31      ; see Geoff Chappell: The Product Suite
            xor eax, eax
            bts eax, esi
            and ax, ovi.wSuiteMask      ; extra long line requires JWasm or AsmC
            mov ebx, Enum$(eax, VER_SUITE_BACKOFFICE, VER_SUITE_BLADE, VER_SUITE_COMPUTE_SERVER, VER_SUITE_DATACENTER, VER_SUITE_ENTERPRISE, VER_SUITE_EMBEDDEDNT, VER_SUITE_PERSONAL, VER_SUITE_SINGLEUSERTS, VER_SUITE_SMALLBUSINESS, VER_SUITE_SMALLBUSINESS_RESTRICTED, VER_SUITE_STORAGE_SERVER, VER_SUITE_TERMINAL, VER_SUITE_WH_SERVER)
            .if byte ptr [ebx]!="?"
                  Print Mid$(ebx, 11), " "
            .endif
      Next
      PrintLine CrLf$, "ProductType", Tb$, Mid$(Enum$(ovi.wProductType, VER_NT_WORKSTATION, VER_NT_DOMAIN_CONTROLLER, VER_NT_SERVER), 8)
      lea eax, ovi.szCSDVersion
      wPrintLine "CSDVersion", wTb$, eax, wCrLf$      ; Unicode
  .endif
  add esp, RTL_OSVERSIONINFOEXW

  Inkey CrLf$, "---- hit any key ----"
  Exit
EndOfCode            ; see MSDN


Output for Win7-64:
Code: [Select]
RtlGetVersion   6.1 SP 1.0 build 7601
Suite mask      0300: SINGLEUSERTS PERSONAL
ProductType     WORKSTATION
CSDVersion      Service Pack 1

dedndave

  • Member
  • *****
  • Posts: 8748
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #284 on: October 04, 2015, 11:37:25 AM »
XP - not much help - lol

i guess that would formatted as "5.1.2600 SP 3.0"

Code: [Select]
RtlGetVersion   5.1 SP 3.0 build 2600
Suite mask      0100: SINGLEUSERTS
ProductType     WORKSTATION
CSDVersion      Service Pack 3