I made mods for the UASM program.
I work with mixed C++ and ASM files.
Keeping the structure definitions the same required attention.
That's why I created a C_HEADER directive in UASM (similar to INCLUDE). Which receives a .h file as a parameter, runs the H2INC program on the .h file and reads the generated .inc file.
c_header <fastSTEP.h>
Hi csobasm,
Welcome to the Forum.
We already have an include file set created for Uasm :
QuoteWinInc - Masm/UASM/JWasm include files for Win32 and Win64
7. About WinInc
WinInc is a set of include files for Masm, UASM, JWasm or PoAsm created by h2incx.
It contains all includes required to build Win32 and Win64 applications or dlls.
https://www.terraspace.co.uk/uasm.html#p9
Why do you need to convert the header (.h) files to inc? Perhaps, you could report the missing elements in the WinInc project.
Quote from: csobasm on July 23, 2023, 02:32:17 AMI created a C_HEADER directive in UASM (similar to INCLUDE). Which receives a .h file as a parameter, runs the H2INC program on the .h file and reads the generated .inc file.
c_header <fastSTEP.h>
That sounds like a cute idea, compliments :thumbsup:
As Vortex writes, most common cases are already served by WinInc (and similar ones), but for specific C/C++ headers your approach could come in handy. Can you post the code? It's a macro, I suppose, right?
Hi csobasm,
Welcome to The MASM Forum. :thumbsup:
zedd
I want to use my own definitions in my mixed mode c++ and assembly projects.
It is important that these constants and structures are synchronized.
It is very convenient that I can directly refer to the .h file in my assembly program.
This is not a macro.
I wrote it in the UASM source. I created a new directive.
C_HEADER
I modified it, in "directive.h", "dirtype.h" and "directiv.c" files.
ret_code C_HEADERDirective( int i, struct asm_tok tokenarray[] )
{
char *name, *p;
DebugMsg1(("C-HEADER enter\n"));
if ( CurrFile[LST] ) LstWriteSrcLine();
i++;
if ( tokenarray[i].token == T_FINAL ) return( EmitError( EXPECTED_FILE_NAME ) );
if ( tokenarray[i].token == T_STRING && tokenarray[i].string_delim == '<' )
{
if ( tokenarray[i+1].token != T_FINAL ) return(EmitErr(SYNTAX_ERROR_EX, tokenarray[i + 1].tokpos));
name = tokenarray[i].string_ptr;
}
else
{
name = tokenarray[i].tokpos;
for ( p = tokenarray[Token_Count].tokpos - 1; p > name && isspace(*p); *p = NULLC, p-- );
}
char* uasm_path[260];
int l = GetModuleFileNameA(0, &uasm_path, 260);
char* p = uasm_path;
p += l;
for (int x = 0; x < l; x++) if (p[0] != '\\') *p-- = 0; else break;
char h2inc_path[260];
char h2inc_param[260];
sprintf(&h2inc_path, "%sh2incx.exe", uasm_path);
sprintf(&h2inc_param, " -v %s -y", name);
PROCESS_INFORMATION processInfo;
ZeroMemory(&processInfo, sizeof(processInfo));
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
if (CreateProcessA(h2inc_path, h2inc_param, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
{
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
char csibe = 0,c;
for (int x = 0; x < 260; x++)
{
c = name[x];
if (c == 0) break;
else if (c == '<') csibe = '>';
else if (c == '.')
{
name[x + 1] = 'i'; name[x + 2] = 'n'; name[x + 3] = 'c'; name[x + 4] = csibe; name[x + 5] = 0;
break;
}
}
if (SearchFile(name, TRUE)) ProcessFile(tokenarray);
}
else printf("h2inc ERROR!!! \r\n");
return( NOT_ERROR );
}
Hi csobasm
Welcome to the Forum.
Do tell. The functions SearchFile and ProcessFile, did you write those yourself?
Those would have to contain some interesting code for sure.
Quote from: csobasm on July 23, 2023, 03:55:48 PMThis is not a macro.
I wrote it in the UASM source. I created a new directive.
C_HEADER
Interesting :thumbsup:
I would suggest two things:
1. Get in contact with johnsa, the main UAsm maintainer, to see if it can become part of UAsm.
2. To avoid running h2incx every time (which costs some milliseconds), check for the presence of name.inc
Quote from: Caché GB on July 23, 2023, 04:14:30 PMDo tell. The functions SearchFile and ProcessFile, did you write those yourself?
Those would have to contain some interesting code for sure.
I modified it to UASM.
These functions are in UASM/directiv.c.
I put it in there, like the normal "include" directive.
Quote from: jj2007 on July 23, 2023, 04:18:36 PMTo avoid running h2incx every time (which costs some milliseconds), check for the presence of name.inc (https://name.inc/)
The .inc file should not be checked. But the date of the .h file and the .inc file.
I did it just so that if the .h file changes during development, the .inc file will follow it
csobasm,
Why not to have a complete and finished set of header files and to convert them once with h2incX? Why all this hassle to modify Uasm?
Quote from: Vortex on July 23, 2023, 09:06:05 PMcsobasm,
Why not to have a complete and finished set of header files and to convert them once with h2incX? Why all this hassle to modify Uasm?
I develop the project's c++ and asm files in parallel.
Structures need to be modified more than once.
I really want more mods in uasm. That was the first.
Might be useful for resource include files too.
Hi,
I think this is a useful feature and I'd be happy to include it in UASM general release. Could you perhaps open a pull request for this on Github?
Thanks!