Author Topic: MasmBasic  (Read 148942 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7628
  • Assembler is fun ;-)
    • MasmBasic
HexDump$
« Reply #420 on: September 18, 2017, 11:18:07 PM »
Install the MasmBasic update 18 September 2017 to get this new feature inspired by the How to read Windows MFT thread:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Inkey "Dump of GetModuleHandle(0):", CrLf$, HexDump$(rv(GetModuleHandle, 0), 90h)
EndOfCode


Options are documented in MbGuide.rtf, as usual.

The other major change is that RichMasm got new menus (more), thanks to LiaoMi :icon14:

Tested on WinXP, Win7-64 (also with Aero, see screenshot below) and Win10, looks OK so far, but let me know if it can be improved :icon_mrgreen:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7628
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #421 on: October 27, 2017, 01:13:11 AM »
Changes in version 26 October:
- online help is updated, e.g. for deb & friends (remember that in RichMasm, hovering over a keyword allows to access help with a right-click)
- see Graphics demo; handling of maps is strongly improved
- HexDump$() got a "dd" option:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Let esi=FileRead$("\Masm32\examples\exampl04\car\car.jpg")    ; Masm32 SDK
  PrintLine HexDump$(esi, 80)   ; show 80 bytes of jpg header
  Inkey HexDump$(esi, 80, dd)   ; same but for use with code
EndOfCode


Output:
Code: [Select]
006337D0  FF D8 FF E0 00 10 4A 46 49 46 00 01 00 01 00 64 ÿØÿà..JFIF.....d
006337E0  00 64 00 00 FF FE 00 1F 4C 45 41 44 20 54 65 63 .d..ÿþ..LEAD Tec
006337F0  68 6E 6F 6C 6F 67 69 65 73 20 49 6E 63 2E 20 56 hnologies Inc. V
00633800  31 2E 30 31 00 FF DB 00 84 00 08 05 06 07 06 05 1.01.ÿÛ.„.......
00633810  08 07 06 07 09 08 08 09 0C 14 0D 0C 0B 0B 0C 19 ................

db  0FFh, 0D8h, 0FFh, 0E0h, 000h, 010h, 04Ah, 046h, 049h, 046h, 000h, 001h, 000h, 001h, 000h, 064h
db  000h, 064h, 000h, 000h, 0FFh, 0FEh, 000h, 01Fh, 04Ch, 045h, 041h, 044h, 020h, 054h, 065h, 063h
db  068h, 06Eh, 06Fh, 06Ch, 06Fh, 067h, 069h, 065h, 073h, 020h, 049h, 06Eh, 063h, 02Eh, 020h, 056h
db  031h, 02Eh, 030h, 031h, 000h, 0FFh, 0DBh, 000h, 084h, 000h, 008h, 005h, 006h, 007h, 006h, 005h
db  008h, 007h, 006h, 007h, 009h, 008h, 008h, 009h, 00Ch, 014h, 00Dh, 00Ch, 00Bh, 00Bh, 00Ch, 019h

- the new MasmBasic version is again compatible with UAsm
- a bug in RichMasm was fixed (if a very big document was loaded, and user opened a small one in the same instance, it crashed)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7628
  • Assembler is fun ;-)
    • MasmBasic
Bugfix
« Reply #422 on: October 30, 2017, 01:15:56 AM »
a) Version 29 October has now the "unique" feature for generation random numbers (->Unique random numbers):
Code: [Select]
Rand(-99, 100, SomeIntegerArray(ecx), unique) ; min, max, destination, unique flag
Full example:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  tests=100
  Dim SomeInteger() As DWORD
  PrintLine Str$("Possible range: %i ... ", -tests/2), Str$(tests/2)
  Let edi="unique numbers: "
  Rand()                                        ; set a seed value
  For_ ecx=0 To tests-1
       Rand(-tests/2, tests/2+1, SomeInteger(ecx), unique)     ; min, max, destination, flag
       Let esi=Str$(" %i ", SomeInteger(ecx))
        .if Instr_(edi, esi)
                inc  ebx                ; oops, we got that one already
        .else
                Let edi=edi+esi         ; remember the last number
        .endif
  Next
  if tests le 100
        PrintLine edi                   ; show the unique numbers
  endif
  Inkey Str$("-- %i errors, hit any key --", ebx)
EndOfCode


Output:
Code: [Select]
Possible range: -50 ... 50
unique numbers:  -13  31  43  11  16  1  -14  -36  -6  21  34  -45  17  -2  -35  39  23  40  7  -1  -5  32  -25  -30  -28  -19  15  -26  0
-29  41  -10  27  -15  22  -33  44  35  -9  29  -12  -16  -24  13  -3  -38  26  -20  -21  20  4  18  -46  36  -23  47  37  49  -34  19  14
10  -37  9  -40  -49  -4  -32  -48  -27  -11  33  2  28  -17  -31  -39  -8  8  -41  -22  24  -50  38  25  -42  6  12  42  -47  48  -44  46
45  3  -7  -18  -43  50  30
-- 0 errors, hit any key --

If you find a duplicate, I owe you a beer, but you must come here to get it :bgrin:

Note that for high numbers of unique random numbers, e.g. tests=30000, it may take a few seconds.


b) another little feature: SetWin$ can now set the text of child controls. Example:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Launch "Notepad.exe SetChildWin.rc", SW_RESTORE, 100  ; give Notepad a few milliseconds to set the caption properly
  .if WinByTitle("SetChildWin.rc - ")
        xchg eax, ecx                   ; set the handle to ecx (MasmBasic won't touch ecx)
        SetWin$ ecx, 15=Replace$(Cat$(Win$(ecx, 15)), "Win$", "Win$#####", 0)   ; replace with an easy-to-spot string
  .endif
EndOfCode


Full project attached, tested with Win7-64 and WinXP. When you hit F6 in RichMasm, the fake rc file for Notepad gets generated from the text between the red Rsrc tags.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7628
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic hits the 400 commands mark
« Reply #423 on: November 08, 2017, 03:00:29 PM »
Version 8 November 2017 is ready to be installed. Changes:

- updated help file, with now 400+ macros documented (also online - use Ctrl F to find commands; but remember the best help option is to use RichMasm, hover over a keyword like Open, then right-click on the word and copy the line that fits your case)

- fDate$() and fTime$() can now take a third parameter to force any language:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Print "Right now, ", fDate$(0, "dddd dd MMMM yyyy "), fTime$(0, "HH:mm:ss"), Str$(", we are in ISO week %i\n", IsoWeek())
  Print fDate$(0, "dddd dd MMMM yyyy ", russian), fTime$(0, "HH:mm"), Str$(", мы находимся в ИСО неделе %i", IsoWeek())
  wMsgBox 0, wCat$(wfDate$(0, "dddd dd MMMM yyyy ", hindi)+wfTime$(0)), "This is Unicode:", MB_OK
EndOfCode

Output:
Right now, Wednesday 08 November 2017 04:55:26, we are in ISO week 45
среда 08 ноября 2017 04:55, мы находимся в ИСО неделе 45


- SetInt can now move the content of ST(0) to xmm0:
  fldpi
  Print Str$("PI=\t%Jf\n", ST(0))
  fmul FP4(100.0)
  SetInt ecx
  Print Str$("100*PI=\t %i\n", ecx)
  fldpi
  fmul FP8(10.0e16)
  SetInt xmm0
  Print Str$("100*PI=\t %i\n", xmm0)


Code: [Select]
Output:
PI=     3.141592653589793238
100*PI=  314
10e16*PI=314159265358979324

- finally, the ternary operator If? can now also take the Zero? and Carry? flags as input (testbed attached):

  xor ecx, ecx
  Print Str$("zero flag set: %i\txor ecx, ecx\n", If?(zero?, 111, 222))         ; prints first number, 111
  or ecx, -1
  Print Str$("zero flag set: %i\tor ecx, -1\n", If?(zero?, 111, 222))   ; prints second number, 222
  stc
  Print Str$("carry set: %i\tstc\n", If?(Carry?, 111, 222))     ; carry is set, prints 111
  clc
  Print Str$("carry set: %i\tclc\n", If?(Carry?, 111, 222))     ; carry clear, prints 222

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7628
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #424 on: November 11, 2017, 04:56:37 AM »
Minor bugfix for the Gdi+ template (RichMasm: File/New Masm source, click on Gdi+), to be inserted after the include line:
Code: [Select]
include \masm32\MasmBasic\Res\MbGui.asm
MenuChecked MACRO inx
  bt guiMenuFlags, inx
  setnc al
  EXITM <al>
ENDM

This line in the Event Menu handler choked:
Code: [Select]
  invoke ShowWindow, hMap, If?(MenuChecked(europe), SW_SHOW, SW_HIDE) ; show the Europe map?