I upload three simple projects.
To help you, put the files of each project in the bin folder,
as I describe in my post :Using CoderStudio Tools
After build each project, delete its files from the bin folder
and put the files of the other project.
Manos.
Thanks for the examples. Here is how to build the dialog box example with a batch file :
\pcc32\bin\pcc32.exe /I\pcc32\include /c Frame.c
\pcc32\bin\rc32.exe /I\pcc32\include Dialog.rc
\pcc32\bin\link32 /LIBPATH:\pcc32\lib /SUBSYSTEM:WINDOWS Frame.obj Dialog.res kernel32.lib user32.lib shell32.lib gdi32.lib comctl32.lib msvcrt.lib
Here is a classical window example.
Bitmap from file example.
Very good example Vortex.
Note:
With CoderStudio IDE you can mix assembly and C modules.
Soon I 'll upload your project using CoderStudio IDE.
Manos.
Open with CoderStudio IDE the BmpFromFile.sdp file
and build the project.
Manos.
Hi Manos,
Thanks, it works as expected.
When we see that the pcc32 is able to compile UASM from source ?
Now, missing headers, hanging,...
Quote from: TimoVJL on February 14, 2019, 08:28:04 AM
When we see that the pcc32 is able to compile UASM from source ?
Now, missing headers, hanging,...
Could you send me the 32 bit source to try it ?
Manos.
This well known site:
https://github.com/Terraspace/UASM
An example to save the icon of an executable :
#include <windows.h>
#include <olectl.h>
const IID __cdecl IID__IPicture =
{ 0x7BF80980, 0xBF32, 0x101A, { 0x8B, 0xBB, 0x00, 0xAA, 0x00, 0x30, 0x0C, 0xAB } };
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
PICTDESC pd;
HICON hIcon;
HMODULE hModule;
IPicture *pBitmap;
IStream *pStream;
LONG pcbSize;
HGLOBAL hGlobal;
LPVOID IconAddr;
HANDLE hFile;
DWORD bWritten;
// load the test executable and the associated icon
hModule = LoadLibrary("Test.exe");
hIcon = LoadIcon(hModule,MAKEINTRESOURCE(100));
// initialize the PICTDESC structure
pd.cbSizeofstruct = sizeof(PICTDESC);
pd.picType = PICTYPE_ICON;
pd.icon.hicon = hIcon;
// create the OLE image
OleCreatePictureIndirect(&pd,&IID__IPicture,TRUE,(void **)&pBitmap);
// create the destination stream to save the icon
CreateStreamOnHGlobal(NULL,TRUE,(LPSTREAM *)&pStream);
// save the icon to the stream
pBitmap->lpVtbl->SaveAsFile(pBitmap,(LPSTREAM)pStream,TRUE,&pcbSize);
// get the address of the icon in memory
GetHGlobalFromStream(pStream,&hGlobal);
IconAddr = GlobalLock(hGlobal);
// write the icon to disc
hFile= CreateFile("Smiley.ico",GENERIC_WRITE,0,0,
CREATE_ALWAYS,0,0);
WriteFile(hFile,IconAddr,pcbSize,&bWritten,0);
CloseHandle(hFile);
// release the pointers
pBitmap->lpVtbl->Release(pBitmap);
pStream->lpVtbl->Release(pStream);
return 0;
}
Quote from: TimoVJL on February 14, 2019, 08:28:04 AM
When we see that the pcc32 is able to compile UASM from source ?
Now, missing headers, hanging,...
Download the
Additional Includes and put the new header files
in the
include folder.
Manos.
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c
Quote from: TimoVJL on February 17, 2019, 11:27:53 PM
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c
Today I 'll upload an updated include folder.
Manos.
Quote from: Manos on February 18, 2019, 12:03:18 AM
Quote from: TimoVJL on February 17, 2019, 11:27:53 PM
missing signal.h io.h sys/stat.h
pcc32.exe hangs in equate.c
The
include files and the
pcc32 are updated to avoid hanging.
Downlad
pcc32 from: http://www.manoscoder.gr/mysite/coderstudio.htm
Manos.
Still some errors and equate.c hangs.
C:\code\UAsm\UASM-master\H\codegenv2.h(112): error:
More than 25 errors. Compilation stoped.
251 errors
C:\code\UAsm\UASM-master\hll.c
22 errors
C:\code\UAsm\UASM-masterX\macro.c(66): error: Syntax error: ; expected
1 errors
#ifdef __WATCOMC__
static _inline char HexDigit( char x )
#elif defined(_MSC_VER)
static _inline char HexDigit( char x ) // line 66
#else
static char HexDigit( char x )
#endif
{
x &= 0xF;
return((x > 9) ? (x - 10 + 'A') : (x + '0'));
}
pcc32 is for Windows projects.
If UASM has been builded with another compiler, you should do changes in the source.
Manos.
As I found in your code there is: static _inline etc.
pcc32 accepts inline functions when enable the switch: /C99
Also instead of _inline you must write: inline
Manos.
OK. -D_inline=inline helps with macro.c and hll.c
equate.c hangs and codegen.c have errorsC:\code\UAsm\UASM-masterX\H\codegenv2.h(8): error: Enumerated type 'instr_group' previously defined
C:\code\UAsm\UASM-masterX\H\codegenv2.h(7): warning: Previous declaration of 'instr_group' here
C:\code\UAsm\UASM-masterX\H\codegenv2.h(9): error: Multiple declaration of 'GP1'
...
C:\code\UAsm\UASM-masterX\H\codegenv2.h(111): error: Multiple declaration of 'M32UINT'
C:\code\UAsm\UASM-masterX\H\codegenv2.h(112): error: Multiple declaration of 'M64UINT'
C:\code\UAsm\UASM-masterX\H\codegenv2.h(112): error:
More than 25 errors. Compilation stoped.
251 errors
So pcc32 don't support #pragma once ?
pcc32 support #pragma once
But #pragma once must include in header files.
Manos.
equate.c + headers for testing.
Quote from: Manos on February 18, 2019, 07:05:59 AM
pcc32 support #pragma once
But #pragma once must include in header files.
Manos.
This fixed it
#pragma once
#ifndef _CODEGENV2_H_INCLUDED
#define _CODEGENV2_H_INCLUDED
...
#endif // _CODEGENV2_H_INCLUDED
OK.
Manos.
You forgot to include the equate.c file for testing.
Manos.
It should be in test_equate.zip
In test2.zip that #pragma once issue.
An inline assembly example based on the Nasm syntax :
#include <windows.h>
#include <stdio.h>
char msg[] = "Hello world!";
char title[] = "pcc32";
void WriteMessage(void)
{
asm{
push 0
push title
push msg
push 0
call MessageBox
}
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WriteMessage();
return 0;
}
Good example.
The option: /SUBSYSTEM:WINDOWS is unnecessary
because Link32 has it as default.
Have a look at: http://masm32.com/board/index.php?topic=7681.0
Manos.
Creating an MD5 Hash from File Content :
https://docs.microsoft.com/en-us/windows/desktop/SecCrypto/example-c-program--creating-an-md-5-hash-from-file-content
Source code built with pcc32
liblzg built with pcc32
Quoteliblzg is a minimal implementation of an LZ77 class compression library. The main characteristic of the library is that the decoding routine is very simple, fast, and requires no memory.
In general, liblzg does not compress as well as zlib, for instance. On the other hand the decoder is very simple and very fast - ideal for systems with tight memory limits or limited processing capabilities.
Also, the decompression routine is easliy ported to just about any conceivable programming language (assembly language, JavaScript, etc).
http://liblzg.bitsnbites.eu
Simple dialog box example.
Quick example using msvcrt.lib supplied with pcc32 :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
printf PROTO C :DWORD,:VARARG
.data
string db '%s',13,10,0
.code
main PROC C uses esi ebx argc:DWORD,argv:DWORD
mov ebx,argc
mov esi,argv
@@:
invoke printf,ADDR string,DWORD PTR [esi]
add esi,4
dec ebx
jnz @b
ret
main ENDP
END
With thanks to Manos helping me to understand the Nasm style inline assembly, here is a quick example to calculate the size of a function :
#include <stdio.h>
int testfunc(int x,int y,int *pSize)
{
int result;
int temp;
asm
{
mov edx,label1
dec edx
l1:
inc edx
// Search for the RET ( 0xC3 ) instruction
cmp byte [edx], 0xC3
jne l1
mov dword [temp],edx
}
result=x;
result+=y;
*pSize=1+(int)temp-(int)testfunc;
label1:
return result;
}
int main(void)
{
int fSize;
testfunc(10,20,&fSize);
printf("Size of the function testfunc = %d bytes\n",fSize);
return 0;
}
Quotesplitter.exe splits a large file into megabyte chunks for transmission. It will also recombine them.
https://www.digitalmars.com/splitter.c
Compiling the code :
set PATH=%PATH%;\pcc32\bin
pcc32.exe /MM /I\pcc32\include /c splitter.c
link32 /SUBSYSTEM:CONSOLE /LIBPATH:\pcc32\lib /NEV splitter.obj kernel32.lib user32.lib msvcrt.lib