News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MasmBasic

Started by jj2007, October 06, 2009, 08:24:57 PM

Previous topic - Next topic

jj2007

Updated with new functions:

   Insert My$(n)
   Delete My$(n)
   mov A$, New$(100, HEAP_ZERO_MEMORY)   ; 100 zero-initialised bytes
   mov esi, New$(1000)         ; may contain garbage (ok for reading in a known # of bytes)

   MsgBox 0, Win$(hWnd), "The title of the main window:", MB_OK
   .if WinByTitle("- Mozilla", 4)   ; search bits: 4=full word, case sensitive
      Print Win$(eax), 13, 10
   .else
      Print "no Firefox window open", 13, 10
   .endif
   Let Files$(n)=String$(32767, 0)         ; assigns a zero-initialised buffer to Files$(n)
   mov eax, String$(32768-1, "A")         ; assigns a buffer initialised with A to eax
   Print String$(15, "+x")         ; prints +x+x+x+x+x+x+x+x+x+x+x+x+x+x+x
   mov esi, FileRead$("MyFile.dat")   ; creates a string on the heap and reads in the specified file
   Launch "Notepad.exe"
   Launch "Notepad.exe MyNewFile.txt"
   Launch "Notepad.exe MyNewFile.txt", SW_MINIMIZE
   Launch "Notepad.exe MyNewFile.txt", SW_MAXIMIZE, 2000   ; cmd, show, timeout in ms

   deb 1, "The first loop", ecx, esi$, edi$, MyReal10, ST(1)
   deb 2, "Second loop:", al, ecx, esi$, $My$
   The debug macro preserves registers but not flags
   can show FPU registers once but trashes them afterwards
   the string content of registers can be shown by using esi$
   global and local variables can be shown as strings by using e.g. $buffer
   cancelling deb 1, ... does not cancel deb 2, ..., so you can test several loops in one go
   deb 1, ... deb 4, ... are being displayed, while deb 5, writes to a file:
   deb 5, "ToFile", eax, esi$, edi$ saves contents (without showing them) to DebLog.txt

Download version 4 on top of thread.

hutch--

JJ,

While I remember inbetween database servers not working etc ... with a tool that has as much development as RichMasm, it would be to its advantage to be able to specify how and where it gets set up in terms of paths of any support files it needs to run. Probably just a dialog box with path slots and common dialog boxes would do the job but it would make it a lot easier for potential users to get it going and configure it the way they like.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

jj,
While taking a quick view on your macros, I've found the macro 'cStyle$'. There are some bugs in it: e.g. for an escape sequence followed by an single character ("\nX") or for two or more esc.seq. in a row ("\n\t\n"). I've modified your macro a bit, so that it works as expected (hopefully) -> file attached.

regards, qWord
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: hutch-- on October 16, 2009, 08:58:29 AM
JJ,

While I remember inbetween database servers not working etc ...
Indeed this post and the following by qWord were not signalled as unread by the forum software - probably related to their hardware problems

Quote
with a tool that has as much development as RichMasm, it would be to its advantage to be able to specify how and where it gets set up in terms of paths of any support files it needs to run. Probably just a dialog box with path slots and common dialog boxes would do the job but it would make it a lot easier for potential users to get it going and configure it the way they like.

Hutch,
Valid point, no doubt. RichMasm/MasmBasic follow your own logic that hard-coded paths are easier to maintain; so, if a user extracts the archive to the root folder of the Masm32 drive with "use folder names" (WinZip) or similar set, the tree will be created with the two folders \masm32\masmbasic and \masm32\RichMasm. That setup works fine, to the point that most if not all examples in \masm32\examples assemble by just hitting hard the F6 button. If they don't, such as \masm32\examples\advanced\wrep\wrep.asm, then it might not be RichMasm's fault.

Now of course there are situations where an experienced user might want to tweak the settings. You can do so by studying File/Configure project, and if that is not enough, by editing \masm32\RichMasm\Res\bldallRM.bav and \masm32\RichMasm\Res\bldallRM.bax - but be warned that currently they are not protected from being overwritten by a new installation.
RichMasm's "makeit.bat" is generated on the fly as \masm32\RichMasm\Res\bldallRM.bat and is composed of bldallRM.bav (default variables), user-defined OPT_xxx variables, and bldallRM.bax.
I am using RichMasm for creating normal executables, dll's and libraries, and up till now I have never had to revert to a manual makeit.bat; therefore I wonder which option you miss? Maybe I can add it to *.bax; otherwise, one could also insert a switch
IF EXIST makeit.bat (
makeit.bat
exit
ENDIF

... into the bldallRM.bav.
bldallRM.bax is a pretty clever template, but clearly there are limits. What I definitely not like is sources that assume that paths are set by the user in the environment variables; a source posted here that starts with include windows.inc has good chances to be ignored. The Masm32 setup is hardcoded and therefore newbie-friendly; and so is RichMasm. But concrete proposals for improvement are always welcome...

Cheers,
JJ

jj2007

Quote from: qWord on October 16, 2009, 02:44:36 PM
jj,
While taking a quick view on your macros, I've found the macro 'cStyle$'. There are some bugs in it: e.g. for an escape sequence followed by an single character ("\nX") or for two or more esc.seq. in a row ("\n\t\n"). I've modified your macro a bit, so that it works as expected (hopefully) -> file attached.

regards, qWord


Hi qWord,
Thanks a lot, looks very convincing. I had written this one some time ago and then forgot about it, indeed it's not even used by MasmBasic, but cStyle$() could be handy in some situations. The next update will contain your version, with credits.

By the way: I repeatedly had problems with @CatStr, see e.g. in the Dim macro:
;; @CatStr(<nustr db ">, MacName$, <", 0>) ; produces garbage
tmp$ CATSTR <nustr db ">, MacName$, <", 0> ; works fine
tmp$

Is that a known ml.exe bug, or is it by design??

qWord

Quote from: jj2007 on October 19, 2009, 08:51:04 AM
By the way: I repeatedly had problems with @CatStr, see e.g. in the Dim macro:
;; @CatStr(<nustr db ">, MacName$, <", 0>) ; produces garbage
tmp$ CATSTR <nustr db ">, MacName$, <", 0> ; works fine
tmp$

Is that a known ml.exe bug, or is it by design??
The problem is, that there are two valid interpretations for this (IMO):
nustr   db ">, MacName$, <", 0
and
nustr   db "...",0
So, to be on the save site, you should use exclamation marks when quotes occures inside angle brackets:
@CatStr(<nustr db !">,%MacName$, <!", 0>)
;(the % was also missing here (which is needed to expand textmacros or equations inside a macro-function call)
; -> this produce somethink like '??0011' instead of the macro-local's content)

the same applies for angle bracket inside quoted text:
IFIDNI some,<">"> ; => error A2046:missing single or double quotation mark in string
ENDIF

IFIDNI some,<"!>"> ; works
ENDIF

FPU in a trice: SmplMath
It's that simple!

hutch--

JJ,

The reasoning was this simple, while I would not try and alter the creative genius of RichMasm the basics of QE is that it is configurable in a number of ways so it can be set up to do more or less whatever you want in terms of where its installed, where you want any accessories, paths set in the menu.ini etc ....

I use another copy of it for the basic development I still do from time to time and it lives in another place with different accessories, menu options and binaries.

The only reason for making the suggestion was that you have done so much work on Richmasm that it would help people who want to play with it if they could manually configure it and add bits to it as they need them.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on October 19, 2009, 10:54:46 PM
The reasoning was this simple, while I would not try and alter the creative genius of RichMasm the basics of QE is that it is configurable in a number of ways so it can be set up to do more or less whatever you want in terms of where its installed, where you want any accessories, paths set in the menu.ini etc ....

Hutch,
Point taken. The new version (attached on top of thread) allows users to keep their own version of various settings in a dedicated User folder. For example, you can create your own version of keyboard shortcuts.

Another addition: The help file following immediately after [&Help] in menus.ini will be opened when pressing F1.

QuoteAlthough RichMasm and MasmBasic are configured in a flexible way,
taking account of exe, dll and lib sources,
you can copy these files to satisfy highly specific requirements:

\masm32\RichMasm\Res\menus.ini
\masm32\RichMasm\Res\Keywords.ini
\masm32\RichMasm\Res\BldAllRM.bav
\masm32\RichMasm\Res\BldAllRM.bax

Copy them into \masm32\RichMasm\User, and edit them according to your needs.

Note that \masm32\RichMasm\User\bldallRM.bat will be generated by RichMasm from
- BldAllRM.bav,
- the OPT_xxx user options set in your source,
- BldAllRM.bax.
Both bav and bax must be present (obviously, it makes no sense to edit bldallRM.bat).

Fumbling with bav and bax is recommended only to users who have a thorough
understanding of batch files.

jj2007

Quote from: qWord on October 16, 2009, 02:44:36 PM
jj,
While taking a quick view on your macros, I've found the macro 'cStyle$'. There are some bugs in it: e.g. for an escape sequence followed by an single character ("\nX") or for two or more esc.seq. in a row ("\n\t\n"). I've modified your macro a bit, so that it works as expected (hopefully) -> file attached.

regards, qWord


Hi qWord,
I can't get it to work:

   Print cStyle$("\nHow\nare\nyou?")  ; OK
   MsgBox 0, cStyle$("How\nare\nyou?"), "Hi", MB_OK ; shows only "How"

Somehow a zero byte gets inserted - by the way in both your and my version. Will look into it asap.

On top of thread I posted a new version whose deb macro preserves the FPU and the flags.

qWord

have you used jwasm? masm throws an error for:
MsgBox 0, cStyle$("How\nare\nyou?"), "Hi", MB_OK ; shows only "How"

You can solve the problem by adding angle brackets around the parameter 'text' (MsgBox):

invoke MessageBox, dlg, reparg_offset(<&text>), reparg_offset(<&title>), style


FPU in a trice: SmplMath
It's that simple!

qWord

I've seen, that your unicode macros wData and wChr$ creates ascii strings that are converted at runtime - this is unnecessary: I've rewritten them (modification of cStyle$), so that this runtime-step is dropped. This two macros can easily changed to support ascii (if your interested in). If you don't like the escape sequences I've choose, then you only have to change/remove them in the ifidn/elseifidn/endif-Block.


     ; create unicode string,  allowed Esc.Seq.: \n    = new line
    ;                                           \0    = 0
    ;                                           \t    = tab
    ;                                           \a\b  = ()
    ;                                           \l\r  = <>
    ;                                           \x    = !
    ;                                           \\    = \
    ;                                           \q    = "
    ;                                           \s    = '
    ; blank arguments are ignored, this applies also to "" and ''
    wData Some,"\a1\b\t x = 12q\n\a2\b\t y = 2x\n\a3\b\t x = y\n\t\a1\b,\a2\b =\r \a3\b\n\a4\b\t12q = 24q",10,13, 10,13,"\l'some senseless words\x'\r"
    %echo @CatStr(<sizeof Some = >,%(SIZEOF Some))
    invoke MessageBoxW,0,OFFSET Some,wChr$("\qQuotes\q",'\\"are simple"'),MB_OK
FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: qWord on October 21, 2009, 11:57:00 PM
I've seen, that your unicode macros wData and wChr$ creates ascii strings that are converted at runtime - this is unnecessary

Actually, this is by design: My wChr$ occupies half as much space in the .data section; not a big deal but we are stingy, aren't we? ;-)

Your version works fine but chokes a) with JWasm and b) with ml and with quoted strings of size 4, e.g. wChr$("1234"). Testbed below.

include \masm32\MasmBasic\MasmBasic.inc

Use_qWord = 1
if Use_qWord
include wData.txt
endif

.code
start:
; these two choke with the qWord version:
; mov eax, wChr$("1234")
; invoke MessageBoxW, 0, wChr$("1234"), wChr$("I am a Unicode box:"), MB_OK
invoke MessageBoxW, 0, wChr$("Hello Masm32 forum"), wChr$("I am a Unicode box:"), MB_OK
Exit

end start

OPT_Icon MasmBasic
OPT_Assembler ml

hutch--

JJ,

I know that the development of the code to make the coffee is probably some way off but in the mean time I have another suggestion that may fill the gap until you develop that code. how abourt a used defined menu that orders your choice of coffee from a cafe of your choice ?


Short Black, www.maroiscafe.it/orders.htm
Long Black, www.Rositas.com/getitnow.htm
Espresso,www.gastrinomicdelights.com/tryyourluck.htm
TurkishBlack,www.yavash_yavash.tr


PS: I want a copy of the coffee making code when you finish developing it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

Quote from: jj2007 on October 22, 2009, 09:24:06 AM
not a big deal but we are stingy, aren't we? ;-)
in case of clocks ? - yes  :bg

Quote from: jj2007 on October 22, 2009, 09:24:06 AM
Your version works fine but chokes a) with JWasm
There are still bugs in jwasm's macros system. In this case the problem comes from the 'ifidn x,<!">', which seems not to remove the exclamation mark. I've solve this problem by removing it - masm accept this also.

Quote from: jj2007 on October 22, 2009, 09:24:06 AM
with ml and with quoted strings of size 4, e.g. wChr$("1234"). Testbed below.
OPATTR allow them as immediates, so that they are treated as numbers - problem fixed  :bg



FPU in a trice: SmplMath
It's that simple!

jj2007

Quote from: hutch-- on October 22, 2009, 10:00:41 AM
Espresso,www.gastrinomicdelights.com/tryyourluck.htm

Hutch,
Are you sure it's gastrinomicdelights?? That sounds a bit like the gastritis you will get from really strong code coffee...
Quote
PS: I want a copy of the coffee making code when you finish developing it.
Promised. It may take a while, though :bg