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

zedd151

Quote from: jj2007 on June 25, 2023, 12:59:04 AM
Quote from: zedd151 on June 25, 2023, 12:35:18 AM'Select proc or macro' does not select proc or macro

You must select the word proc or the word macro, then you right-click.
Okay, only works some of time...
in attached example displays error "not found:      endp"
selecting 'proc' for WndProc for example.
edit=removed attachment as it has served its purpose.

jj2007

I see; it's a coding style issue: you leave four spaces before WinMain proc and WinMain endp. The algo expects
WinMain proc
...
WinMain endp


Sorry, it won't work for you. For consistency, I never leave spaces before the xxx proc or the xxx macro. Inside macros, when there is more than one ENDM, only the last one has no spaces.

Do your 4 spaces serve a specific purpose?

zedd151

Of course, formatting. I detest hard tabs.  :tongue: 
okay then, I'll keep this in mind if selecting a procedure or macro comes up in a real situation.

jj2007

Quote from: zedd151 on June 25, 2023, 01:17:53 AM
Of course, formatting. I detest hard tabs.  :tongue:

Tabs or spaces, what for at the beginning of a proc? That's the central unit in your source, it should be left-aligned imho :cool:

All my procs follow this formatting:
DrawMyRect proc hDC
Local hBrush, whatever
  CreateAndSelect(hDC) ; one arg: set the DC (right after the locals)
  mov hBrush, CreateAndSelect(brush, Blue) ; the hBrush is not really needed
  .if !eax
MsgBox 0, "error", "Hi", MB_OK
  .endif
  ReleaseObjects ; no leaks please ;-)
  ret
DrawMyRect endp


First line, locals, last line: no blanks
Level 1: two spaces
Level n: n tabs

For good readability...

zedd151

Quote from: jj2007 on June 25, 2023, 01:20:50 AM
Tabs or spaces, what for at the beginning of a proc? That's the central unit in your source, it should be left-aligned imho :cool:
Actuall I haven't the slightes idea why I do it. I had started that practice years ago and the reasoning behind it is lost to history.   :rolleyes:  Very odd.

jj2007

Quote from: zedd151 on June 25, 2023, 01:24:26 AM
Quote from: jj2007 on June 25, 2023, 01:20:50 AM
Tabs or spaces, what for at the beginning of a proc? That's the central unit in your source, it should be left-aligned imho :cool:
Actuall I haven't the slightes idea why I do it. I had started that practice years ago and the reasoning behind it is lost to history.   :rolleyes:  Very odd.

I checked some sources in \Masm32\examples. Hutch did procs like I do, but left spaces before mytest macro :rolleyes:

StrykerX

Would this be a good starting point for learning Assembly? Keen to give it a crack!

Caché GB

jj2007's MasmBasic confused the h*ll out of when I first got started with MASM. Sorry jj.

It's a very complicated macro system for doing assembly. "Basic" is becuase it has a Basic
language like syntax.
Caché GB's 1 and 0-nly language:MASM

jj2007

Quote from: Caché GB on July 06, 2023, 10:28:37 AM
jj2007's MasmBasic confused the h*ll out of when I first got started with MASM. Sorry jj.
:biggrin:

QuoteIt's a very complicated macro system for doing assembly. "Basic" is becuase it has a Basic
language like syntax.

include \masm32\include\masm32rt.inc

.code
start:
  print "Masm32 is great"
  MsgBox 0, "Hello World", "Basic style", MB_OK
  exit

end start


Guess what? This is not MasmBasic, it's "HutchBasic" aka "Masm32 SDK". I grew up with GfaBasic, Hutch grew up with PowerBasic. That's one reason why we understood each other very well :tongue:

Re "very complicated macro system": under the hood, yes. For the user, it's actually very simple to do things like
Let esi="Now esi is a pointer to a string", or
include \masm32\MasmBasic\MasmBasic.inc
  Init
  .if Instr_(FileRead$("\Masm32\menus.ini"), "[&Project")
PrintLine "QEditor has a project section: ", Left$(eax, 200)
  .else
PrintLine "Nope, no project section in your QEditor menus"
  .endif
EndOfCode


Quote from: StrykerX on July 06, 2023, 10:03:35 AM
Would this be a good starting point for learning Assembly? Keen to give it a crack!

Opinions differ wildly. My extremely biased take on this is that using MasmBasic, you can do everything that you can do with the standard Masm32 libraries plus deb and Recall and a few (500+) others. Example:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  mov eax, 12345
  cdq
  mov ecx, 123
  deb 4, "Before the div:", eax, edx, ecx
  div ecx
  deb 4, "What happened to the registers?", eax, edx, ecx
EndOfCode


Output:
Before the div:
eax             12345
edx               0
ecx             123

What happened to the registers?
eax             100
edx              45
ecx             123


Check the File/MasmBasic help menu in RichMasm:

jj2007

MasmBasic of 26.7.23 features:

- the MbMod macro
- when you select a number in RichMasm and press Ctrl N, the dec, hex & binary representations can be copied to the clipboard.

jj2007

MasmBasic of 28.7.23 fixes a minor bug with wStr$(number): if no format string was present, it spit out Ansi instead of Unicode. Works fine now :thumbsup:

NoCforMe

Quote from: StrykerX on July 06, 2023, 10:03:35 AMWould this be a good starting point for learning Assembly? Keen to give it a crack!

Wellll, since you got one biased answer, from the author of MasmBasic, JJ, here's another answer biased in the other direction.

Mind you, I have nothing bad to say about his creation. It's magnificent, a megalithic work, a wonderful system that seems to do everything: macros galore, and it slices and dices.

However, my suggestion would be to learn standard assembly language (MASM) first. Why? Because if you start with MasmBasic, for one thing you'll get spoiled, and if you make a transition to standard MASM you'll probably be disappointed. Plus I think the less insulated approach of standard asm, having to do everything "by hand", may make you understand the underlying principles better.

But you should definitely try it (MasmBasic) at some point.

(My bias here is that I don't even like to use macros with MASM. I'm pretty much a loner here in that regard.)
Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on July 29, 2023, 01:11:10 PMif you start with MasmBasic, for one thing you'll get spoiled

Good point :thumbsup:

For example, by changing five lines in \Masm32\examples\exampl04\jacts\jacts.asm:

if 1
   include \masm32\MasmBasic\MasmBasic.inc
   uselib winmm   ; see deb below
else
.386
.model flat,stdcall
option casemap:none
...
includelib \masm32\lib\winmm.lib
endif   ; ----- ^ ^ ^ excluded in favour of MasmBasic -----

... you don't change anything. Oh wait: the executable is 4 times bigger... and you can use the deb macro from now on ;-)

jj2007

What's new in MasmBasic version 2 August 2023?

a) Coloured rounded ownerdraw buttons, with text that moves some pixels to the right and down when the button is pressed:



b) the fastest Hex$() ever:
  Let o$=New$(40000000h)+"END"
  REPEAT 5
  NanoTimer()
  mov edi, o$
  xor ebx, ebx
  .Repeat
    Hex$(ebx, edi)
    add edi, QWORD
    inc ebx
  .Until ebx>=8000000h
  Print NanoTimer$(), Str$(" for writing %i MB\n", ebx/1048576)

Output:
315 ms for writing 128 MB
366 ms for writing 128 MB
361 ms for writing 128 MB
310 ms for writing 128 MB
312 ms for writing 128 MB

Same with standard Masm32 SDK hex$() - invoke dw2hex, ebx, edi:
1961 ms for writing 128 MB
1967 ms for writing 128 MB
1940 ms for writing 128 MB
1991 ms for writing 128 MB
1968 ms for writing 128 MB

Not to mention that you can use invoke crt_sprintf, edi, chr$("%00x"), ebx, too - but it takes 26 seconds :biggrin:

2B||!2B

Nice looking rounded buttons. Do you use GDI+ or D2D?