The MASM Forum

General => The Campus => Topic started by: mabdelouahab on October 18, 2015, 12:39:10 AM

Title: isolated file
Post by: mabdelouahab on October 18, 2015, 12:39:10 AM
Can I create  and generate an isolated file during assembling? - programmatically(Macro) not manual , (For example: create and generate IDL file while assembling). Please anyone has an idea let us help me,
Title: Re: isolated file
Post by: nidud on October 18, 2015, 01:58:02 AM
deleted
Title: Re: isolated file
Post by: jj2007 on October 18, 2015, 03:02:26 AM
Why don't you write from within your assembly code?

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  FileWrite "1.tmp", "hello mabdelouahab, how are you?"
  Inkey FileRead$("1.tmp")
EndOfCode
Title: Re: isolated file
Post by: TouEnMasm on October 18, 2015, 03:44:00 AM

an  IDL file is a very special file only usable by midl.Midl generate .h .c and more with it.
You can't do that with masm or any asm compiler.
Need more explain of what you want to do and why you need an idl file.
Title: Re: isolated file
Post by: jj2007 on October 18, 2015, 04:18:26 AM
The idl file is plain text, no problem to generate it from Assembler code.

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Open "O", #1, "tmp.idl"
  PrintLine #1, "module HelloApp"
  PrintLine #1, "{"
  PrintLine #1, "  interface Hello"
  PrintLine #1, "  {"
  PrintLine #1, "  string sayHello();"
  PrintLine #1, "  oneway void shutdown();"
  PrintLine #1, "  };"
  PrintLine #1, "};"
  Close
  Launch "idlcompilerorwhatever.exe tmp.idl"
  Inkey Err$()
EndOfCode
Title: Re: isolated file
Post by: mabdelouahab on October 18, 2015, 04:30:44 AM
hi jj2007,ToutEnMasm,nidud,
I thank you for the idea but I'm looking for this  during assembling; not while executing :(
Of course if possible :P
Title: Re: isolated file
Post by: TouEnMasm on October 18, 2015, 05:01:56 AM
ECHO with > textfile.txt (or better a pipe)  are able to do that at assembling time,no problem

The problem  is to generate the line of an IDL file who look like this:
Quote
//--------------------------------------------------------------------------------------------------------
// DXGI object hierarchy base interfaces
//--------------------------------------------------------------------------------------------------------

[
    object,
    uuid( aec22fb8-76f3-4639-9be0-28eb43a67a2e ),
    local,
    pointer_default(unique)
]
interface IDXGIObject :
    IUnknown
{
    //ULONG   Release();
    HRESULT SetPrivateData(
        [in, annotation("_In_")] REFGUID Name,
        [in] UINT DataSize,
        [in, annotation("_In_reads_bytes_(DataSize)")] const void *pData );
    HRESULT SetPrivateDataInterface(
        [in, annotation("_In_")] REFGUID Name,
        [in, annotation("_In_")] const IUnknown *pUnknown );
    HRESULT GetPrivateData(
        [in, annotation("_In_")] REFGUID Name,
        [in, out, annotation("_Inout_")] UINT *pDataSize,
        [out, annotation("_Out_writes_bytes_(*pDataSize)")] void *pData );
    HRESULT GetParent(
        [in, annotation("_In_")] REFIID riid,
        [out, retval, annotation("_COM_Outptr_")] void **ppParent );
};

Title: Re: isolated file
Post by: GoneFishing on October 18, 2015, 05:09:37 AM
Why not use batch file for this purpose ?
It could be much more comfortable  for your task.
Title: Re: isolated file
Post by: mabdelouahab on October 18, 2015, 06:56:27 AM
Quote from: ToutEnMasm on October 18, 2015, 05:01:56 AM
ECHO with > textfile.txt (or better a pipe)  are able to do that at assembling time,no problem
How do I use echo with textfile  in my macro code? :redface:
Title: Re: isolated file
Post by: dedndave on October 18, 2015, 09:31:55 AM
this is an example i keep around, i think Jochen wrote it

include \masm32\include\masm32rt.inc

MBox MACRO pText, pTitle, MB_x
   invoke MessageBox, 0, reparg(pText), reparg(pTitle), MB_x
   EXITM <eax>
ENDM

IsOK MACRO args:VARARG
  cmp args, IDOK
  EXITM <Zero?>
ENDM

.code
start:
   TestCase=0
   if TestCase eq 0
      ; use echo to see the output of a macro - creates no code
      echo IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
   elseif TestCase eq 1
      ; echo with expansion operator - creates code
      % echo IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
   else
      ; the real thing
      .if IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
         MsgBox 0, "That was OK", "Hi", MB_OK
      .else
         MsgBox 0, "That was NOT OK", "Hi", MB_OK
      .endif
   endif
   exit

end start


it can create code, or just output text at assembly-time
Title: Re: isolated file
Post by: mabdelouahab on October 18, 2015, 04:51:01 PM
Good morning dedndave
Quote from: dedndave on October 18, 2015, 09:31:55 AM
it can create code, or just output text at assembly-time

output text to Output window,I ask how to output it to textfile.txt ?
Of course if exist or if it possible :P
Title: Re: isolated file
Post by: hutch-- on October 18, 2015, 05:46:09 PM
What you CAN get is output to the console at assembly time which you can redirect to a file using the console, not MASM. To do any more you would need to write an application that you ran at assembly time to do what you require.
Title: Re: isolated file
Post by: jj2007 on October 18, 2015, 06:28:45 PM
Quote from: mabdelouahab on October 18, 2015, 04:51:01 PMoutput text to Output window,I ask how to output it to textfile.txt ?

As Hutch wrote, you need an application to do that. RichMasm has a built-in option to launch an executable (bat or exe) before calling the assembler (OPT_BatA). Here is an example:
include \masm32\MasmBasic\MasmBasic.inc
  Init
  Inkey FileRead$("~temp.txt") ; open in RichMasm and hit F6
  Kill "~temp.txt" ; make sure you create a fresh one on next build
EndOfCode

OPT_BatA MyBatA.exe Your path is "%path%" ; this creates a text file at assembly time


Sources attached. Open MyBatA.asc first and hit F6; then do the same with UseBatA.asc (of course, this requires a MasmBasic installation (http://masm32.com/board/index.php?topic=94.0)).

P.S.: Try OPT_BatA   MyBatA.exe %date%, %time%
Title: Re: isolated file
Post by: mabdelouahab on October 19, 2015, 01:12:12 AM
I found this file : \masm32\bin\assmbl.bat

\masm32\bin\ml /c /coff %1.asm > \masm32\bin\asmbl.txt

I think it comes out the content to a file asmbl.txt
QuoteAssembling: FTest003.asm

*************
UNICODE Build
*************

---------------- this is a test by ECHO

Can I get rid of headline?
Title: Re: isolated file
Post by: GoneFishing on October 19, 2015, 01:33:52 AM
Yes, use -q (-nologo) switch
Title: Re: isolated file
Post by: qWord on October 19, 2015, 01:59:20 AM
Quote from: mabdelouahab on October 19, 2015, 01:12:12 AMCan I get rid of headline?
I would prefix all echoed lines with a special character and than use a external tool that scans over the output to creates the actual file.
Title: Re: isolated file
Post by: mabdelouahab on October 19, 2015, 02:45:27 AM
Quote from: qWord on October 19, 2015, 01:59:20 AM
Quote from: mabdelouahab on October 19, 2015, 01:12:12 AMCan I get rid of headline?
I would prefix all echoed lines with a special character and than use a external tool that scans over the output to creates the actual file.

I think that the external tool is the best solution and is a good idea
I thank you qWord  :t