Author Topic: MasmBasic  (Read 287306 times)

tenkey

  • Regular Member
  • *
  • Posts: 19
Missing .inc file
« Reply #435 on: October 25, 2018, 08:52:22 AM »
The second example in the MasmBasic guide fails to assemble due to missing DualWin.inc file. I see LibUsed$() example is also using JBasic.inc instead of MasmBasic.inc. MasmBasic Version 25 Dec 2017.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #436 on: October 25, 2018, 11:07:41 AM »
Thanks for the feedback. Did you get any error messages?

Please tell me if the following files are present (this helps me to understand what went wrong):
  \Masm32\MasmBasic\Res\GetPT.exe
  \Masm32\MasmBasic\Res\StructInfo.txt

- Extract the attached files to \Masm32\MasmBasic\Res
- Try again to build the example; if that doesn't work, try to run \Masm32\MasmBasic\Res\GetPT.bat

Note that the 64-bit examples build also with MASM; to do so, add an OPTion as follows:
Code: [Select]
include \masm32\MasmBasic\Res\JBasic.inc ; OPT_Assembler ML
However, RichMasm prefers UAsm and will try to install it if it's not present at \Masm32\bin\Uasm64.exe
You can do that manually, too: install UAsm64, i.e. extract \Masm32\bin\Uasm64.exe

Let me know if it works, please.

2B||!2B

  • Member
  • **
  • Posts: 75
Re: MasmBasic
« Reply #437 on: November 08, 2018, 02:09:01 PM »
Hi jj,

Is there a Unicode Split$() version?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #438 on: November 08, 2018, 07:34:28 PM »
No, but it could be implemented. Something like this works already - not Unicode but Utf8:

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Let esi="Введите\nтекст\nздесь"
  For_ ct=0 To Split$(esi, "\n", My$())-1
        PrintLine "[", My$(ct), "]"
  Next
EndOfCode


Output:
Code: [Select]
[Введите]
[текст]
[здесь]

What exactly do you want to do?

2B||!2B

  • Member
  • **
  • Posts: 75
Re: MasmBasic
« Reply #439 on: November 08, 2018, 09:16:31 PM »
Cool, but i don't want to assign my string to a new variable. My string is like "####STRING####STRING" etc
So i use #### as string delimiter.
But i used wInstr and it worked fine for me. Although i have to add a null terminator after each substring, this way i can use the string in it's source.

tenkey

  • Regular Member
  • *
  • Posts: 19
Re: MasmBasic
« Reply #440 on: November 09, 2018, 06:38:43 PM »
Thanks for the feedback. Did you get any error messages?
*** Assemble using \masm32\bin\UAsm64 /c /coff /Zd /Zi /Zf tmp_file.asm ***
UASM v2.46, Dec  8 2017, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

*** using Res\JBasic32.lib ***
\masm32\MasmBasic\Res\JBasic.inc(558) : Error A2106: Cannot open file: "\Masm32\MasmBasic\Res\DualWin.inc" [ENOENT]
 \masm32\MasmBasic\Res\JBasic.inc(558): Included by
  Tmp_File.asm(1): Main line
Quote
Please tell me if the following files are present (this helps me to understand what went wrong):
  \Masm32\MasmBasic\Res\GetPT.exe
  \Masm32\MasmBasic\Res\StructInfo.txt
GetPT.asm exists, but not GetPT.exe.
StructInfo.txt exists.
Quote
- Extract the attached files to \Masm32\MasmBasic\Res
Extracted the files and ran GetPT.exe in a command prompt. Had to  turn off security.
The example (32-bit) assembled and ran.
I re-enabled security and now the file names \masm32\masmbasic\mbguide.exe and \masm32\masmbasic\tmp_file.exe are flagged as suspicious. polink can't create them - access denied.
I can probably create the exe files in another directory, but that means i'll have to use a custom BAT file for each example.

*** Assemble using \masm32\bin\UAsm64 /c /coff /Zd /Zi /Zf tmp_file.asm ***
UASM v2.46, Dec  8 2017, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

*** MasmBasic version 25.12.2017 ***
Tmp_File.asm: 6 lines, 2 passes, 99 ms, 0 warnings, 0 errors

*** Link  MbGuide.obj rsrc.res  using polink, sub Console /debug /mapinfo:lines***
Writing debug information
Compacting CodeView information
POLINK: fatal error: Access is denied.
*** Link error ***

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #441 on: November 09, 2018, 07:01:33 PM »
So it's all a security thing. If I used an AV, I would simply exclude the whole \Masm32 folder. Assembly code is considered unsafe because it's unusual by the dumb AV brigade, see our dedicated sub-forum AV Software sh*t list 8)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic update
« Reply #442 on: November 25, 2018, 12:48:54 PM »
It has been a while since MasmBasic was updated - grab the new version here. Below an alphabetical list of the new macros added. In RichMasm, check File/MasmBasic help for the new keywords. Let me know if one is missing.
Code: [Select]
AddMru MACRO pTxt
ArrayStripDuplicates MACRO numID
Ceil MACRO arg, dest
ClosePipe MACRO arg:=<2>
ExeFromExt$ MACRO argExt, opt:=<2>
Floor MACRO arg, dest
Geo$ MACRO arg1:=<GEO_FRIENDLYNAME>, arg2:=<G
HeapStrings MACRO
LineInput MACRO dest$
Lset MACRO args:VARARG
MruText$ MACRO arg
MulQQ MACRO argQ1, argQ2, pDest
rCosinus MACRO arg
ResFile$ MACRO id
rSinus MACRO arg
SetAxisX MACRO args:VARARG
SetAxisY MACRO args:VARARG
SetMru MACRO fname ; SetMru "filename.ini"
SetRgbCol MACRO dest, noarg
ShowPlaces MACRO arg:=<1>
StoreHeader MACRO pSHeader
TitleCase$ MACRO arg
uClip$ MACRO MbLimit
uFileOpen$ MACRO args:VARARG
uFileSave$ MACRO args:VARARG
uSetWin$ MACRO arg1:REQ
uWin$ MACRO h1, cHandle
wExeFromExt$ MACRO argExt, opt:=<2>
wGeo$ MACRO arg1:=<GEO_FRIENDLYNAME>, arg2:=<
Win64 MACRO

2B||!2B

  • Member
  • **
  • Posts: 75
Re: MasmBasic
« Reply #443 on: November 29, 2018, 07:15:57 AM »
Hi jj,

I could not get the Try/Catch to work.

Code: [Select]
Init tc
Is causing unresolved external symbol.


Code: [Select]
error LNK2001: unresolved external symbol _MbTryCatch@0
fatal error LNK1120: 1 unresolved externals


How do i solve it?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #444 on: November 29, 2018, 09:38:05 AM »
Without seeing your full code, I can't help you much. This works:

include \masm32\MasmBasic\MasmBasic.inc         ; simple Try/Catch demo - use as a template
  Init tc                               ; initialise MasmBasic with Try/Catch (aka SEH)
  PrintLine "This code was built with ", @AsmUsed$()
  mov eax, 123                  ; use 123 as the dividend
  cdq                           ; and sign-extend it to edx
  xor ecx, ecx
  Try
        div ecx
        PrintLine "Congrats, it worked!!!!"     ; you won't see this line
  Catch
        PrintLine "Sorry, div ecx failed"
  Finally
        PrintLine Str$("Ouch, we had an exception in source line %i at\nAddress\t", LastEx(line)), Hex$(LastEx(addr)), CrLf$, "Code", Tb$, Hex$(LastEx(code)), CrLf$
        Inkey "The OS reports:", CrLf$, LastEx(info)
EndOfCode

OPT_TryCatch on       ; tells MasmBasic's preferred editor RichMasm to select the source line that triggered the first exception


Code: [Select]
This code was built with UAsm64
Sorry, div ecx failed
Ouch, we had an exception in source line -6 at
Address 004010D4
Code    C0000094

The OS reports:
{ERRORE DI EXCEPTION}
Divisione intera per zero.
EIP     004010D4
Code    C0000094

2B||!2B

  • Member
  • **
  • Posts: 75
Re: MasmBasic
« Reply #445 on: November 29, 2018, 12:52:49 PM »
The code you posted does not compile if used inside a procedure

Code: [Select]
Error A2093: Cannot nest procedures
Error A2142: Unmatched block nesting: MbTryCatch


Try/Catch does not work inside a procedure. I tried using it outside a procedure and it compiled.
Is there a way to fix this so it can be used inside a procedure?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #446 on: November 29, 2018, 01:07:32 PM »
I cannot diagnose what went wrong if you don't post the complete code. This works fine:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc ; simple Try/Catch demo - use as a template
  Init tc, console ; initialise MasmBasic with Try/Catch (aka SEH), and output errors to console
  PrintLine "This code was built with ", @AsmUsed$()
  call MyTest
  Exit

MyTest proc
  mov eax, 123 ; now we'll do something illegal in line 13...
  cdq
  xor ecx, ecx
  Try
; ****** the line below will be selected a second after the program finishes: ******
div ecx ; dividing by zero is a criminal act, right?
Print Str$("div succeeded, eax is %i\n", eax) ; you will not see this message
  Catch
Print Str$("div failed, eax is still %i\n\n", eax)
  PrintLine Str$("Ouch, we had an exception in source line %i at\nAddress\t", LastEx(line)), Hex$(LastEx(addr)), CrLf$, "Code", Tb$, Hex$(LastEx(code)), CrLf$
  PrintLine "The OS reports:", CrLf$, LastEx(info)
  Finally
  ret
MyTest endp

EndOfCode ; OPT_TryCatch on ; activate jump to the error line in the source code

Output:
Code: [Select]
This code was built with UAsm64
div failed, eax is still 123

Ouch, we had an exception in source line 13 at
Address 0040110A
Code    C0000094

The OS reports:
{ERRORE DI EXCEPTION}
Divisione intera per zero.
EIP     0040110A
Code    C0000094

2B||!2B

  • Member
  • **
  • Posts: 75
Re: MasmBasic
« Reply #447 on: November 29, 2018, 01:11:24 PM »
Which code you want me to post?
I have only tried to compile your code that you posted earlier.
So does the Init TC needed to be called outside a procedure?
and also, do we need to call it once in every thread?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 10557
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #448 on: November 29, 2018, 07:24:16 PM »
Which code you want me to post?

Your complete code. My crystal ball is not working today, I must see what you are trying to assemble...

HSE

  • Member
  • *****
  • Posts: 1383
  • <AMD>< 7-32>
Re: MasmBasic
« Reply #449 on: November 30, 2018, 03:16:20 AM »
It has been a while..

- could not open MenusRM.ini
- problem with @AsmUsed$()