Microsoft Visual C++
Posted: Wed Jun 08, 2005 11:33 am
Does anyone have any information on producing a freestanding binary (such as an OS kernel), using MS Visual C++ (7)?
Thanks
Thanks
The Place to Start for Operating System Developers
http://f.osdev.org/
I use it as an editor, because I like the cod highlighting and auto-indenting. It's much easier to just use GCC to compile the kernel though.srg wrote:I don't think it's possible, microsoft's compiler isn't designed to do that. You could use it as a code editor though.
Code: Select all
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Yd"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
IgnoreStandardIncludePath="true"
StringPooling="true"
MinimalRebuild="false"
BasicRuntimeChecks="0"
SmallerTypeCheck="false"
RuntimeLibrary="2"
StructMemberAlignment="1"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
UndefineAllPreprocessorDefinitions="true"
OmitDefaultLibName="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalOptions="/MACHINE:I386 /FIXED /ALIGN:1024"
LinkIncremental="2"
IgnoreAllDefaultLibraries="true"
GenerateDebugInformation="false"
SubSystem="1"
EntryPointSymbol="NdosEntryPoint"
BaseAddress="0x70000"
TargetMachine="0"
FixedBaseAddress="2"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Yd"
Optimization="0"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
IgnoreStandardIncludePath="true"
StringPooling="true"
MinimalRebuild="false"
BasicRuntimeChecks="0"
RuntimeLibrary="2"
StructMemberAlignment="1"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
UndefineAllPreprocessorDefinitions="true"
OmitDefaultLibName="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
CommandLine="ml /c /coff AKERNEL.ASM
uild
"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
LinkLibraryDependencies="false"
AdditionalOptions="/MACHINE:I386 /FIXED /ALIGN:1024"
AdditionalDependencies="AKERNEL.OBJ"
LinkIncremental="1"
IgnoreAllDefaultLibraries="true"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="0"
EnableCOMDATFolding="0"
EntryPointSymbol="NdosEntryPoint"
BaseAddress="0x70000"
TargetMachine="0"
FixedBaseAddress="2"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
Code: Select all
#define NULL 0
typedef void (__cdecl *_PVFV)(void);
#pragma data_seg(".CRT$XCA")
_PVFV __xc_a[] = { NULL };
#pragma data_seg(".CRT$XCZ")
_PVFV __xc_z[] = { NULL };
#pragma data_seg()
#pragma comment(linker, "/merge:.CRT=.data")
void __cdecl _initterm (
_PVFV * pfbegin,
_PVFV * pfend
)
{
while ( pfbegin < pfend )
{
if ( *pfbegin != NULL )
(**pfbegin)();
++pfbegin;
}
}
static _PVFV * pf_atexitlist = 0;
static unsigned max_atexitlist_entries = 0;
static unsigned cur_atexitlist_entries = 0;
void __cdecl _atexit_init(void)
{
max_atexitlist_entries = 32;
pf_atexitlist = (_PVFV *)0x500000; /** use your kernel malloc to allocate space **/
}
void InitializeConstructors()
{
_atexit_init();
_initterm(__xc_a, __xc_z);
}
Code: Select all
.386P
.MODEL FLAT
.CODE
LOWORD equ [0]
HIWORD equ [4]
__aullrem proc near
assume cs:_TEXT
push ebx
DVND equ [esp + 8]
DVSR equ [esp + 16]
mov eax,HIWORD(DVSR)
or eax,eax
jnz short L1
mov ecx,LOWORD(DVSR)
mov eax,HIWORD(DVND)
xor edx,edx
div ecx
mov eax,LOWORD(DVND)
div ecx
mov eax,edx
xor edx,edx
jmp short L2
L1:
mov ecx,eax
mov ebx,LOWORD(DVSR)
mov edx,HIWORD(DVND)
mov eax,LOWORD(DVND)
L3:
shr ecx,1
rcr ebx,1
shr edx,1
rcr eax,1
or ecx,ecx
jnz short L3
div ebx
mov ecx,eax
mul dword ptr HIWORD(DVSR)
xchg ecx,eax
mul dword ptr LOWORD(DVSR)
add edx,ecx
jc short L4
cmp edx,HIWORD(DVND)
ja short L4
jb short L5
cmp eax,LOWORD(DVND)
jbe short L5
L4:
sub eax,LOWORD(DVSR)
sbb edx,HIWORD(DVSR)
L5:
sub eax,LOWORD(DVND)
sbb edx,HIWORD(DVND)
neg edx
neg eax
sbb edx,0
L2:
pop ebx
ret 16
__aullrem endp
public __aulldiv
__aulldiv proc near
assume cs:_TEXT
push ebx
push esi
DVND equ [esp + 12]
DVSR equ [esp + 20]
mov eax,HIWORD(DVSR)
or eax,eax
jnz short L1
mov ecx,LOWORD(DVSR)
mov eax,HIWORD(DVND)
xor edx,edx
div ecx
mov ebx,eax
mov eax,LOWORD(DVND)
div ecx
mov edx,ebx
jmp short L2
L1:
mov ecx,eax
mov ebx,LOWORD(DVSR)
mov edx,HIWORD(DVND)
mov eax,LOWORD(DVND)
L3:
shr ecx,1
rcr ebx,1
shr edx,1
rcr eax,1
or ecx,ecx
jnz short L3
div ebx
mov esi,eax
mul dword ptr HIWORD(DVSR)
mov ecx,eax
mov eax,LOWORD(DVSR)
mul esi
add edx,ecx
jc short L4
cmp edx,HIWORD(DVND)
ja short L4
jb short L5
cmp eax,LOWORD(DVND)
jbe short L5
L4:
dec esi
L5:
xor edx,edx
mov eax,esi
;
L2:
pop esi
pop ebx
ret 16
__aulldiv endp
_TEXT ends
end
+
END
That would be great! I didn't even know that was possible!kataklinger wrote: Once again: YES it is possible. You can use MSVC++ compiler, but I had some problem using MS linker (and I think it cannot produce binary file, only PE) but MinGW works fine with MSVS (error reporting is not so good but....).
Currently I'm working on asm (NASM) syntax coloring support for MSVS.NET 2003, so if someone is interested I will publish it on Internet when I finish it.