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

BytePtr

Got this error: "Sorry, MasmBasic needs SSE2."


Too bad. Im not going to buy new PC because of MasmBasic.

Sad, i thought i could use it. But it seems, i must forget it.

TmX

Quote from: BytePtr on May 15, 2011, 09:34:36 AM
Got this error: "Sorry, MasmBasic needs SSE2."


Too bad. Im not going to buy new PC because of MasmBasic.

Sad, i thought i could use it. But it seems, i must forget it.

Are you using an old CPU, prior to Pentium 4?

jj2007

Quote from: BytePtr on May 15, 2011, 09:34:36 AM
Got this error: "Sorry, MasmBasic needs SSE2."
Too bad. Im not going to buy new PC because of MasmBasic.

Sorry for that. SSE2 was introduced ten years ago...

I actually wrote MasmBasic to overcome the limitations of an old 16-bit Basic dialect that I still use frequently; so MB is not meant to support old hardware.

There are actually people who claim that 32-bit assembler is obsolete now. Given that 16-bit Windows apps still work fine on the latest Win7 64-bit professional editions, and that the added value of going from 16 to 32 bits was much, much higher than the step from 32 to 64, I am optimistic that a 32-bit SSE2 language will be useful for some decades to come :bg

BytePtr

Quote from: TmX on May 15, 2011, 11:54:38 AMAre you using an old CPU, prior to Pentium 4?

AMD Duron, 1.6 GHz.

Of course i would like to have new and more powerful PC, with tons of RAM and video memory and very fast HDD.

But i don't play any high end games, (what i play only is: GTA1, GTA2, GTA3, Vice and San), that's all, and they all work perfectly on my PC), i can watch my movies with my current PC fine, i can make my all development on this PC fine.

Basically im just wasting my money with buying new PC or making new from different new pieces. Because i will never use that power.

And i didn't know that AMD Duron doesn't support SSE2, i thought it does.

jj2007, no problems, if i find some good offers or something like that, i will of course upgrade.
I can sell old parts, add some money and make new PC from pieces (best available in my town PC shops).

And i can test MasmBasic again.

qWord

Quote from: BytePtr on May 15, 2011, 08:26:38 PMi can watch my movies with my current PC fine
just for interest: also HD films?
FPU in a trice: SmplMath
It's that simple!

BytePtr

Nope, i don't care much about that, HD or not, i will watch movie once and that's enough, if i see the action, that's all i need.
Of course preferably better quality than Youtube offers for example. Not their HD but these, 640x480, etc resolutions in fullscreen.


But about MasmBasic, when i first saw this topic, i thought: wow, finally, compiler that makes programming with assembler alot easier.
But it's actually INC file.

But that's not the problem, i looked into manual and .INC file, looks very interesting and useful.
Hopefully i can soon test it.


Keep up the good work, JJ2007.

dedndave

the AMD Duron supports SSE (1)
maybe you can get some functionality - or at least, see how it works - to help you in writing your own code

on the other hand, maybe Jochen can work in some non-SSE fallbacks   :P

jj2007

Quote from: BytePtr on May 15, 2011, 08:36:54 PM
Keep up the good work, JJ2007.

Thanks :bg

Update 23 May 2011 (below top of thread):

1. Interface to GNU Scientific Library (see this thread)
  Note this does NOT imply that MasmBasic gets a GNU licence. You can use the GSL as you like, but MasmBasic source code remains copyrighted and closed source - so make sure you understand the implications of using an external library with a GNU license.

2. CreateInvoke - a quick way to use invoke for dynamically linked routines:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc
   
Init
[/color]
   mov ebx, rv(LoadLibrary, Chr$("urlmon"))
   mov
CreateInvoke(Web2File, 5*DWORD), rv(GetProcAddress, ebx, Chr$("URLDownloadToFileA"))
   
invoke Web2File, 0, Chr$("http://www.masm32.com/board/index.php?action=unread", 59, "all"), Chr$("NewReplies.htm"), 0, 0
   invoke FreeLibrary, ebx
   Inkey Str$("\nCongrats, the file has %i bytes. See it now?\n", Lof("NewReplies.htm"))
   .if al=="y"
      Inkey FileRead$("NewReplies.htm")
   .endif
   Exit
end start

Variants:
   mov CreateInvoke(zebox1, 4*dword), MessageBox
   invoke zebox1, 0, Chr$("Text"), Chr$("Title"), MB_OK
   mov CreateInvoke(zebox2, dword, :Dword, dWord, :DWORD), MessageBox
   invoke zebox2, 0, Chr$("Text"), Chr$("Title"), MB_OK

jj2007

#248
The version of 23 May had a bug in its implementation of gsl - it used STDCALL instead of C.
The good news is that fixing the bug required adding a "C" variant of CreateInvoke:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; Download
   Init

;   whateverproc = any proc or result of GetProcAddress etc
   mov CreateInvoke(whatever1, 3*dword, REAL8), whateverproc
;   mov CreateInvoke(whatever2, vararg), whateverproc   ; Error A2094: Vararg requires C calling convention
   mov CreateInvokeC(whatever3, dword, REAL8, dword, REAL4), whateverproc
   mov CreateInvokeC(whatever4, vararg), whateverproc

;   example how to use the created invoke:
   invoke whatever3, 123, FP8(123.456), 456, FP4(456.789)
   Inkey "OK"
   
Exit

whateverproc proc  thedd1, thereal8:REAL8, thedd2, thereal4:REAL4
   PrintLine "Ciao"  ; could do something more useful, actually :wink
   ret
whateverproc endp

end start

Download is here as usual.

jj2007

Update 14 June 2011 (archive):

- CatchRTE:
MasmBasic can throw a variety of runtime errors, such as "file not found" etc. ; note that
after showing them, MB will call ExitProcess. This can lead to tricky situations if you use
MB in a dll. To prevent killing your main process, use MbCatchRTE as follows:
   MyAlgo proc uses esi edi ebx arg1, arg2
   LOCAL var1, var2
            MbCatchRTE SafeRet   ; any label will do
            ... code that may trigger a runtime error...
   SafeRet:   ret      ; will gracefully return, with pop ebx edi esi and retn 2*4
   
MyAlgo endp


- Erase works now also for numeric arrays.

jj2007

Update 17 June:
1. minor Str$() change - this is now legal syntax:
.code
MyR8 REAL8 123.456
start: mov esi, offset MyR8
Print Str$("Wow, a Real whatever: %f\n", REAL8 PTR [esi])


2. Print #1:numbytes, ptrBuffer could misbehave for large buffers because it HeapAlloc's a buffer for the buffer. No problem for buffers under 300MB, but well, some BloatWareTM products require really fat files, so we now have a PrintBuffer macro that is much less versatile but respects the limits of the OS.
QuotePrintBuffer
[/color]   PrintBuffer #1:eax, esi   ; #file:bytes, pBuffer - corresponds to Print #1:eax, esi syntax
   PrintBuffer #1, esi, eax   ; #file, pBuffer, bytes - same code generated but different syntax
Rem   - returns # of bytes written in edx, Win API WriteFile return code in eax
   - use this macro instead of e.g. Print #1:eax, esi to avoid memory problems
Key   pb1

jj2007

30 June 2011:

- There are still some fans of console apps around, so the goodies today are Locate and Input$. More in the Windows Console Input thread.

- Reading and writing to the registry could be a lot easier:
QuoteGetRegVal
   PrintLine GetRegVal("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path", "no path found"), CrLf$
   EnvVars equ "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"   ; long paths: use an equate
   Print GetRegVal(EnvVars,"PROCESSOR_IDENTIFIER", "unknown"), CrLf$   ; get to know your CPU...
   print GetRegVal(EnvVars, "PROCESSOR_IDENTIFIER", "unknown"), 13, 10   ; same with Masm32 print macro
   PrintLine GetRegVal("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","PROCESSOR_IDENTIFIER", "unknown"), CrLf$            ; same with full path
   PrintLine GetRegVal("HKCR\.doc", 0, "documents"), " are files with ending *.doc"
   PrintLine GetRegVal("HKEY_CLASSES_ROOT\.bax", 0, "unknown"), " are files with ending *.bax"
   ; this line would fail with a run-time error because the key does not exist and there is no default value given:
   ; PrintLine GetRegVal("HKEY_CLASSES_ROOT\.bax", 0), " are files with ending *.bax"
   PrintLine GetRegVal("HKCU\Console","FaceName", "Arial"), " is your default console font"   ; works fine
   ; this line would produce garbage because GetRegVal can only be first para in Let and Print combinations:
   ; PrintLine "Your default console font is ", GetRegVal("HKCU\Console","FaceName", "Arial")
   ; workaround with Cat$ (no need for cleanup with Clr$):
   PrintLine Cat$("Your default console font is "+GetRegVal("HKCU\Console","FaceName", "Arial"))
   ; workaround with a permanent string, e.g. in esi:
   Let esi=GetRegVal("HKCU\Console","FaceName", "Arial")
   PrintLine "Your default console font is ", esi, " with FontFamily ", Hex$(GetRegVal("HKCU\Console","FontFamily"))
   Clr$ esi   ; if you don't use esi in another Let esi=..., a Clr$ esi should free the heap
Rem   - returns in eax either a pointer to a string, or a DWORD
   - if you provide a default value, GetRegVal returns it even if the key and/or the value are not present
Key   grv(

SetRegVal
   SetRegVal
"HKCU\TheKey","TheValueName", "NewString")
   SetRegVal "HKEY_CURRENT_USER\Console\JJ", "NewValue", 12345      ; creates new REG_DWORD
   SetRegVal "HKCU\Console\JJ", "NewValue", 54321            ; changes existing value
   SetRegVal "HKEY_CURRENT_USER\Console\JJ", 0, "New default value"   ; 0: sets (Default) to a string
   ; do not replace an existing REG_SZ with a dword - this will produce an exception:
   ; SetRegVal "HKEY_CURRENT_USER\Console\JJ", 0, 123
   ; existing REG_DWORD receives a DWORD string pointer - this works but is meaningless and bug-prone:
   ; SetRegVal "HKEY_CURRENT_USER\Console\JJ", "NewValue", "A string"
   ; tries to create a new key, will fail with a run-time error:
   ; SetRegVal "HKEY_CURRENT_USER\Console\NoSuchKey", "NewValue", 123
Rem   - returns in eax the original new value
   - you are not allowed to create a new key, but you can create a new REG_SZ or REG_DWORD value
Key   -
[/color]

The rules are simple:
  if key found: return string or dword in eax
  if key or value not found:
   - get with default: return default dword or string
   - get, no default: trigger run-time error
   - set: always run-time error

Sample output:
C:\Programmi\ImageMagick-6.6.5-Q8;%SystemRoot%\system32;%SystemRoot%;%SystemRoot
%\System32\Wbem;D:\DB_CIRCS\WEBSITE\0_SERVER\PhpBin;D:\masm32\bin;D:\masm32\incl
ude;C:\Programmi\FreeArc\bin

x86 Family 6 Model 14 Stepping 8, GenuineIntel
x86 Family 6 Model 14 Stepping 8, GenuineIntel
x86 Family 6 Model 14 Stepping 8, GenuineIntel

Word.Document.8 are files with ending *.doc
unknown are files with ending *.bax
Lucida Console is your default console font
Your default console font is Lucida Console
Your default console font is Lucida Console with FontFamily 00000036

jj2007

Small but significant change in version 30Juneb: The user can choose if a GetRegVal/SetRegVal failure triggers a run-time-error (with ExitProcess etc - default behaviour), or just a 'failure flag' in edx. Check MbRegValRTE in \masm32\MasmBasic\MbGuide.rtf

jj2007

One more hint related to the registry: If you plan to create a new string value, the 30Juneb version will create a REG_DWORD instead (there is no problem with existing REG_SZ values). Replace line 1295 of \masm32\MasmBasic\MasmBasic.inc as follows:
Quote  tmp$ SUBSTR <rkNew>, 1, 1
  is INSTR <"'>, tmp$
  if is

Quote  tmp$ SUBSTR <rkNew>, 1, 1
  is INSTR <"'(>, tmp$
  if is

The added ( allows to use e.g. (eax) to force a string value. Most MasmBasic string macros return some variant of (eax) in brackets anyway.

Quoteinclude \masm32\MasmBasic\MasmBasic.inc
   Init
   
mov eax, chr$("Masm32 is great!!")
   SetRegVal
"HKCU\Console", "FancyNewValue", (eax)  ; force REG_SZ
   Inkey "ok?"
   Exit
end start

jj2007

Update 14 July here with docu for DDE conversations with Ms Word:

Quote   SendWordCommands INIT   ; prepare a DDE session; Word must be running
   .if eax
      SendWordCommands "[FileNewDefault:InsertFile °\"D:\Masm32\include\Windows.inc°\"]"
      SendWordCommands Chr$("[InsertFile ", 34, "D:\Masm32\include\WinExtra.inc", 34, "]")
      Let esi=FileRead$("\masm32\RichMasm\OpenDocInWord.bas")
      SendWordCommands esi   ; send the contents of the BAS file
      SendWordCommands "[MsgBox °\"Cute°\"]"   ; show a box in Ms Word
   .else
      MsgBox 0, "MS Word doesn't answer", "Sorry", MB_OK
   .endif
   SendWordCommands
EXIT


Rem   - swc init returns the DdeConnect retval in eax
   - DDE uses ancient WordBasic; get the help file here ; to make it appear in
     RichMasm's Help menu, save it as \masm32\RichMasm\Help\WrdBasic.hlp
   - a sequence is included in [squared brackets]
   - multiple commands can be separated by a colon (:)
   - for strings, use either the escape sequence °\" (Alt 248, 92, 34) or Chr$("xx", 34, "xx") - see above
   - you can also use Let or Cat$ to send commands to MS Word
   - it is your responsibility to respect legality when using this feature