News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using WCRT with MASM

Started by Jibz, January 15, 2005, 04:40:19 PM

Previous topic - Next topic

Jibz

A while back hutch-- suggested writing a version of the WCRT C runtime library using stdcall so it could be used from MASM. After a bit of pondering, I chose to let WCRT be and instead try to make MASM generate something that could be linked with it.

The package contains an include file for wcrt.lib, and two examples.

main.asm shows how a WCRT runtime compatible main function can be made in asm, and calls a couple of C functions.

winmain.asm shows how a WCRT runtime compatible WinMain function can be made in asm.

If you do not use the I/O functions or others that require initialization of the runtime, you can of course just call directly from your code without resorting to this 'main-trick' :U.

[attachment deleted by admin]

hutch--

 :U

Thanks Jibz,

Making you C runtime replacement available for MASM is a good idea. Both examples work fine and the size is right.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Faiseur

#2
Hi Jibz,

thanks for this work.

Note: If i include masm32.lib in my code, conflict with "atol" procedure in masm lib and "atol" proto in wcrt.inc ("PROC and prototype calling conventions conflict")


French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

Xor Stance

I had a question. which compilers better code, Masmor C? I only heard of low-level C can use optimize code.

Jibz

Xor Stance,

I'm afraid I don't understand your question .. and I can't really see what it has to do with WCRT either.

If you're asking which compiles better code, MASM or C, then you need to understand that MASM is an assembler which just translates your instructions (more or less) directly into the corresponding machine code, whereas a C compiler takes a (somewhat) higher level language and transforms it into machine code.

Thus a C compiler can in theory never outperform an assembly coder .. in practice it usually performs sufficiently well that it doesn't matter.

hutch--

Char,

A compiler and an assembler are different tools with different uses even though they do overlap to some extent but each in their realm can do things that the other cannot do well. Historically they have been used in conjunction with each other to do what each does better and combine the results and this is still a viable option today as both MASM and VC use the same object module format.

A C compiler is as much a management tool as a binary output tool and it is in very large architecture like an operating system the C has long proven its capacity. The person trying to compete with an assembler with a C compiler does not properly understand the difference between the tools. An assembler is tuned for its task range, full instruction capacity, no real design limitations apart from the OS ones and the results in skilled hands is very hard to beat with anything else except thse very hardy few who code bits in HEX.

At the other end constructing an OS in assembler is possible but a very difficult task due to the sheer quantity of code to produce. DOS up to about version 6 had IO.SYS and COMMAND.COM written in MASM but with Windows the massive volume of code excludes this from being viable. Microsoft have used assembler code for bits of GDI and it is still used in some device drivers but writing an OS the size of Windows in assembler as we know it is probably not possible these days.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Xor Stance

Now I read again your first post and I understood.
I'm sorry I just thought the WCRT was to use a different compilation. Since Masm has the common macros with that library you can compile C and
C++ even I guess.

What I doubt is that if inline assembly it's possible, why wouldn't they write a whole os inline in assembly with a vb tool? Wasn't in the traduction already machine code? It must use assembly to make it easier or none has taken the time to do it?

I was thinking if you can make ml 6.15 Visual C preprocessor compile, we can have an os with full-assembly. I remember some people from 3ivx told me that Visual Basic had already the capacity for inline assembly and they didn't need to learn assembler.

In theory, I would still learn assembler even if it's possible. Because it's enjoyable, I can make a powerful tool, etc. I don't think Microsoft will fail that idea to implement the ml 6.15 in a VC; I still have hopes.

Xor Stance