News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Just Getting Into Masm32 And Questions Already

Started by Don-D, August 22, 2012, 02:07:23 PM

Previous topic - Next topic

Don-D

Hi, I've been working with Computers for decades, but I'm mostly self-taught on PCs.  What experience I've had with x86 assembler dates back to the 8086.  Then I got into BASIC, where I pretty much stayed for a long, long time.  The advent of the 386+ changed assembly programming, but I was not a part of that
move.

Then along came inline assembly.  Having programmed assembly on mainframes and knowing some of the advantages (and difficulties), I did a bit of that, but not much.  My last major BASIC language was/is, well, mostly was, PowerBASIC.  But I wanted a BASIC that worked outside of DOS and Windows.  I finally
settled on HotBasic.  You may never have heard of it, but it has a flavor of its own.  Well, actually, it began as an effort to take RapidQ code and compile it,
not just interpret it.  But it grew from there.

HotBasic is less like a wall than it is a dense hedge.  It has some odd gaps here and there, but you put your mind to it, you can mostly code around them.
But what I liked most about it is that the compiler can make 5 kinds of applications, and there is both a Windows and a Linux version.  I got both.

But as strings get longer, you begin to want for some way to do things faster.  Faster in some cases means going to assembler code.  HotBasic supports
its own flavor of Assembler Mnemonics, meaning it's not going 100% in that direction, but it has a good selection.  Only there is some stuff missiong, and
actually I found that there is at least one significant error in its implementation.  Since it is limited in some respects, you may have to use db to put the hex
code in in place of the mnemonic.  Now its to learning enough 386+ code mnemonics to get the job done, compile or assemble it, and move what you need
into your source code or include an .obj file.

HotBasic is rather sparce on how to do assembly code, and my persistance in trying to cover it as part of a forum dedicated to HotBasic got me thrown off
it and another forum today.  Very limited vision on the administrator's part.  Anyway, one of the final things that the developer of HotBasic communicated to me is that ml.exe is the only assembler he would consider for use in conjunction with HotBasic, so guess what?  I downloaded Masm32 yesterday and got
it set up.  And it is impressive.  I like that qeditor.exe, although I understand less than half the choices it offers me.

I'm about done here.  I wanted to say Hi, and I wanted to ask one question:  Where can I get a real breakdown on what qeditor offers and does?  I tried
Tools/hex to mnemonic, and I could not see that it did anything.  The icons on the toolbar look fine, but it is hard to tell what they do.  The Help seems pretty skimpy on review.

I might be leaving the impression that I create havoc where I venture.  Not on purpose, but I bought HotBasic over five years ago, and still only understand
about a third of what you can do with it.  It's not that hard, except there is no decent manual or tutorial to guide you.  There are hundreds of example
programs to maybe help you, but you don't have any sense of direction when it comes to what to try next. 

Do I plan to take up assembler full time again?  Hey, I'm 71 now, and I'm planning of getting out of assembler as much as I need to increase the power that
HotBasic is putting in my hands.  Linking a high level language with assembler is a potentially rich environment to get into.  Gives me a useful place to be
these remaining years.

Don-D


hutch--

Hi Don,

Welcome on board, good to see another young fella sharpening his knife in programming again. To properly do x86 assembler you need all of the reference material, the Intel manuals and Windows API reference, for Linux you will have to find your own but there is supposed to be some reasonable stuff available.

I don't know the HotBasic variant but most probably you will need to get the swing of the lower level mnemonic coding techniques unless it provides a macro capacity similar to MASM. Also have a look at JWASM if you are going to write code for Linux, it is highly MASM compatible and does not have the licence limitations that ML.EXE has.

dedndave

welcome to the forum, Don   :t

i am a little surprised Hutch didn't hit on the QE help file   :P
i sometimes think it is easier to write a complex program than it is to document it - lol
that's because it's fun to write the code, and rather mundane to write the help file

i messed with BASIC a little, when i built my first PC
i remember playing with it long enough to figure out a few ways to make it link with an ASM routine
after that, i got a copy of MASM v3 and away i went

once you get your feet wet, Jochen has created a library called MasmBasic that you may enjoy
it is essentially ASM code (macros and subroutines) written using BASIC-like syntax

MichaelW

Hi Don,

I recall that HotBasic at some point was distributed with Microsoft DDK binaries (because somewhere back there I had an online argument with the author :biggrin:). It seems strange that he would have adopted such a difficult route to coding in assembly when he had MASM available.
Well Microsoft, here's another nice mess you've gotten us into.

Vortex


jj2007

Quote from: dedndave on August 22, 2012, 02:29:11 PMonce you get your feet wet, Jochen has created a library called MasmBasic that you may enjoy

Hi Don,
Welcome to the forum :icon14:
Jochen that's me, and MasmBasic is here.
There is HotBasic (PowerBasic, ...) with inline assembler, and there is Masm with inline BASIC:

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   PrintLine String$(39, "x-")    ; must be in an extra line
   mov eax, 123   ; just to prove that this is assembler code ;-)
   Inkey NoTag$(FileRead$("http://masm32.com/board/index.php?topic=463.msg4552")), CrLf$, String$(39, "x-")
   Exit
end start
Output:
x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-
Contextual help project
The MASM Forum Hello jj2007
Show unread posts since last visit.
...
x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-


FileRead$() reads a whole file (from Internet or disk) to a buffer. NoTag$ removes the html tags so that you can read plain text, etc - there are over a hundred Frequently Used Functions, mostly file I/O, arrays and string manipulation, check here for (lousy) documentation.

Of course, you could also combine HotBasic with DLLs written in a mix of "pure" assembler and MasmBasic.
I would be curious to see how HB and MB compare speedwise. My favourite example reads \Masm32\include\Windows.inc from disk and converts all 8000+ hex equates into decimal ones:

include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init               ; library initialisation
  NanoTimer()            ; start the QPC timer; we will use milliseconds resolution
  Recall "\Masm32\include\Windows.inc", MyWin$()   ; reads Windows.inc from disk into the MyWin$() array
  push 0         ; initialise counter
  For_ n=0 To eax-1
   mov ebx, Instr_(1, MyWin$(n), "equ", 5)   ; start at pos 1, 1=case-insensitive, +4=full word
   .if ebx
      mov esi, Val(Mid$(MyWin$(n), ebx+3, 99))
      .if dh && edx!=-127   ; dh=binary or hex, -127 is the "doubtful" flag, we ignore it here
         movzx edx, dl   ; binary strings return usable chars in dl, plus a flag in dh
         lea edi, [ebx+edx+3]   ; index of the string after the match
         inc stack   ; increase counter
         ; change the line using decimal notation; use case-sensitive search for Equ to find changed items
         Let MyWin$(n)=Left$(MyWin$(n), ebx-1)+Str$("Equ %i", esi)+Mid$(MyWin$(n), edi)
      .endif
   .endif
  Next
  pop ecx         ; retrieve counter
  Inkey Str$("Converting %i hex equates in Windows.inc to decimals", ecx), Str$(" took %i ms\n", NanoTimer(ms))
  if 0         ; optional, set to 1 to see the result in Notepad
   Insert MyWin$(0)
   Let MyWin$(0)="echo ### Thank you for using the modified version of Windows.inc ###"
   Store "MyWindows.inc", MyWin$()         ; write all strings to file
   Launch "Notepad.exe MyWindows.inc"
  endif
  Exit
end start

Output: Converting 8071 hex equates in Windows.inc to decimals took 15 ms
What does it take to do the same in HotBasic, and how fast is it?

dedndave


jj2007

Thanks for reminding me, Dave :biggrin:

Quote from: Don-D on August 22, 2012, 02:07:23 PMI'm planning of getting out of assembler as much as I need to increase the power that HotBasic is putting in my hands.  Linking a high level language with assembler is a potentially rich environment to get into.

That's the point. For a long time, I have used dialects of Basic "in the driving seat" with assembler routines for getting more speed. Then I discovered that my Basic code was pretty repetitive: some 20 commands used frequently, some 80 used less frequently, some 500+ used never; combined with extensive use of "inline Windows" in the form of SendMessage hWnd, WM_WHATEVER, 0, 0 etc.

Now I use the opposite: Assember "in the driving seat" with MasmBasic doing the repetitive stuff.
A third option would be HotBasic+(Assembler+MasmBasic). Even VB+MasmBasic works. Almost everything can be combined, the question is really what are your priorities: speeding up some innermost loop, or doing more complex things in assembler, too...

Gunther

Hi Don,

welcome to the forum. :t It seems to me that we know each other from the PB forum. Right? Have a lot of fun.

Gunther
You have to know the facts before you can distort them.