I\'m involved in one of those challenges where you try to produce the smallest possible binary, so I\'m building my program without the C or C++ run-time libraries
I'm pretty sure there's a compiler flag that tells VC++ not to use intrinsics
The source to the runtime library is installed with the compiler. You do have the choice of excerpting functions you want/need, though often you'll have to modify them extensively (because they include features and/or dependencies you don't want/need).
There are other open source runtime libraries available as well, which might need less customization.
If you're really serious about this, you'll need to know (and maybe use) assembly language.
Edited to add:
I got your new test code to compile and link. These are the relevant settings:
Enable Intrinsic Functions: No
Whole Program Optimization: No
It's that last one that suppresses "compiler helpers" like the built-in memset.
Edited to add:
Now that it's decoupled, you can copy the asm code from memset.asm into your program--it has one global reference, but you can remove that. It's big enough so that it's not inlined, though if you remove all the tricks it uses to gain speed you might be able to make it small enough for that.
I took your above example and replaced the memset() with this:
void * __cdecl memset(void *pTarget, char value, size_t cbTarget) {
_asm {
push ecx
push edi
mov al, value
mov ecx, cbTarget
mov edi, pTarget
rep stosb
pop edi
pop ecx
}
return pTarget;
}
It works, but the library's version is much faster.