Skip to content

Commit ff2197f

Browse files
committed
[ZH] Rest of asm code made VC only
1 parent c5cc49c commit ff2197f

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

Dependencies/Utility/Utility/CppMacros.h

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
#pragma once
55

6+
#include <cassert>
7+
#define UNIMPLEMEMTED_ERROR(msg) do { \
8+
assert(("Unimplemented: ", msg, 0)); \
9+
} while(0)
10+
611
#if __cplusplus >= 201703L
712
#define NOEXCEPT_17 noexcept
813
#else

GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void StackDump(void (*callback)(const char*))
7676

7777
DWORD myeip,myesp,myebp;
7878

79+
#ifdef _MSC_VER
7980
_asm
8081
{
8182
MYEIP1:
@@ -86,6 +87,9 @@ _asm
8687
mov eax, ebp
8788
mov dword ptr [myebp] , eax
8889
}
90+
#else
91+
UNIMPLEMEMTED_ERROR("StackDump");
92+
#endif
8993

9094

9195
MakeStackTrace(myeip,myesp,myebp, 2, callback);
@@ -340,6 +344,7 @@ void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip)
340344
gsContext.ContextFlags = CONTEXT_FULL;
341345

342346
DWORD myeip,myesp,myebp;
347+
#ifdef _MSC_VER
343348
_asm
344349
{
345350
MYEIP2:
@@ -351,6 +356,9 @@ _asm
351356
mov dword ptr [myebp] , eax
352357
xor eax,eax
353358
}
359+
#else
360+
UNIMPLEMEMTED_ERROR("FillStackAddresses");
361+
#endif
354362
memset(&stack_frame, 0, sizeof(STACKFRAME));
355363
stack_frame.AddrPC.Mode = AddrModeFlat;
356364
stack_frame.AddrPC.Offset = myeip;

GeneralsMD/Code/Libraries/Source/debug/debug_debug.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <string.h>
3333
#include <new> // needed for placement new prototype
3434
#include <eh.h>
35+
#include <Utility/intrin_compat.h>
36+
#include <Utility/CppMacros.h>
3537

3638
// a little dummy variable that makes the linker actually include
3739
// us...
@@ -271,11 +273,15 @@ bool Debug::SkipNext(void)
271273
// do not implement this function inline, we do need
272274
// a valid frame pointer here!
273275
unsigned help;
276+
#ifdef _MSC_VER
274277
_asm
275278
{
276279
mov eax,[ebp+4] // return address
277280
mov help,eax
278281
};
282+
#else
283+
UNIMPLEMEMTED_ERROR("Debug::SkipNext");
284+
#endif
279285
curStackFrame=help;
280286

281287
// do we know if to skip the following code?
@@ -387,7 +393,7 @@ bool Debug::AssertDone(void)
387393
}
388394
break;
389395
case IDRETRY:
390-
_asm int 0x03
396+
__debugbreak();
391397
break;
392398
default:
393399
((void)0);
@@ -655,7 +661,7 @@ bool Debug::CrashDone(bool die)
655661
}
656662
break;
657663
case IDRETRY:
658-
_asm int 0x03
664+
__debugbreak();
659665
break;
660666
default:
661667
((void)0);

GeneralsMD/Code/Libraries/Source/debug/debug_except.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
//////////////////////////////////////////////////////////////////////////////
2929
#include "_pch.h"
3030
#include <commctrl.h>
31+
#include <Utility/CppMacros.h>
3132

3233
DebugExceptionhandler::DebugExceptionhandler(void)
3334
{
@@ -173,12 +174,16 @@ void DebugExceptionhandler::LogFPURegisters(Debug &dbg, struct _EXCEPTION_POINTE
173174
double fpVal;
174175

175176
// convert from temporary real (10 byte) to double
177+
#ifdef _MSC_VER
176178
_asm
177179
{
178180
mov eax,value
179181
fld tbyte ptr [eax]
180182
fstp qword ptr [fpVal]
181183
}
184+
#else
185+
UNIMPLEMEMTED_ERROR("LogFPURegisters");
186+
#endif
182187

183188
dbg << " " << fpVal << "\n";
184189
}

GeneralsMD/Code/Libraries/Source/debug/debug_stack.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
//////////////////////////////////////////////////////////////////////////////
2929
#include "_pch.h"
3030
#include <imagehlp.h>
31+
#include <Utility/CppMacros.h>
3132

3233
// Definitions to allow run-time linking to the dbghelp.dll functions.
3334

@@ -363,6 +364,7 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx)
363364
{
364365
// walk stack back using current call chain
365366
unsigned long reg_eip, reg_ebp, reg_esp;
367+
#ifdef _MSC_VER
366368
__asm
367369
{
368370
here:
@@ -371,6 +373,9 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx)
371373
mov reg_ebp,ebp
372374
mov reg_esp,esp
373375
};
376+
#else
377+
UNIMPLEMEMTED_ERROR("DebugStackwalk::StackWalk");
378+
#endif
374379
stackFrame.AddrPC.Offset = reg_eip;
375380
stackFrame.AddrStack.Offset = reg_esp;
376381
stackFrame.AddrFrame.Offset = reg_ebp;

0 commit comments

Comments
 (0)