I'm working on a project, written in C++, that involves the injection of source code into an already compiled (and running) process, and so in a few cases I'm required to write inline assembly. This short introduction is to avoid any comment telling me inline assembly probably shouldn't be used.
So, as for my actual question, I've found out C++ had alternative operators, and a few of them, notably and and or reminded me a lot of Python, a programming language I find very pleasant in terms of syntax.
I know using these alternative operators certainly isn't in the best practices and should be avoided, but this is a personal project so code readability for others doesn't bother me too much.
My project is compiled with a MSVC compiler, and my first observation was that these alternative operators do not seem to be defined by default. After a bit of research, I found out one way to enable them was to include <ciso646>
. So mission accomplished, I thought.
But on compiling I found out my inline assembly snippets are now causing compile errors, because they contains asm instructions such as or and and. Yes, the inline assembly is written in lower case. So, the possible workaround would be to uppercase all of my inline assembly snippets, but since I don't like the ALL CAPS RAGE STYLE too much, I'm asking here if there's any other workaround to this problem.
Here's an example of inline assembly causing problems
__declspec (naked) Unit* __fastcall D2CLIENT_GetClientUnit(int nGUID, DWORD dwType)
{
/*
push dwType
mov eax, nGUID & 0x7F
mov edx, ((dwType << 9) + D2CLIENT_6FBBA608)
call D2CLIENT_6FB54E20
*/
__asm
{
push edx
mov eax, ecx
shl edx, 0x09
and eax, 0x7F
add edx, [D2CLIENT_6FBBA608]
call D2CLIENT_6FB54E20
retn
}
}
Thanks