Re: Inline assembley code to be moved to .asm file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"weebo" wrote:
I am trying to compile a C++ program to run in 64bit mode
using Visual Studio
.Net 2005. One of the header files contains the following
assembler code to
check if the debugger is attached (by interrogating the
Thread Information
Block)

__asm
{
push eax // Preserve the registers
push ecx
mov eax, fs:[0x18] // Get the TIB's linear address
mov eax, dword ptr [eax + 0x30]
mov ecx, dword ptr [eax] // Get the whole DWORD
mov dw, ecx // Save it
pop ecx // Restore the registers
pop eax
}

When I compile using the 64bit compiler, I have to move
this inline
assembler code to a .asm file. The problem I have is that
no matter what I
do, I cannot get the code to compile as a .asm file. This
leads me to a
couple of questions - 1) what changes do I need to do to
compile this as a
.asm file and 2) is the thread information block (TIB)
stioll available to be
used in this way? I am also wondering if the
IsDebuggerPresent function will
do the same thing?


MSDN says that inline assembly language is not supported for
64-bit builds. It suggests to use MASM for x64 (ml64.exe)
for that. Also many asm instructions were translated into
compiler intrinsics. Look here for complete list:

"Compiler Intrinsics"
http://msdn2.microsoft.com/en-us/library/ms301440.aspx

Considering your task, it is quite strange why inline
assebly was used while perfectly working API function
exists. IsDebuggerPresent should work with any platform.


.



Relevant Pages

  • [PATCH] Fix constant folding and poor optimization in byte swapping code
    ... Constant folding does not work for the swabXXbyte swapping functions, ... something like "case swab32:" in a switch statement will not compile. ... movzwl %ax, %eax ...
    (Linux-Kernel)
  • RE: [Full-Disclosure] Local variable memory allocation
    ... > profit', but when I compile the examples, I get different ... > Dump of assembler code for function function: ... > End of assembler dump. ... > series gcc. ...
    (Full-Disclosure)
  • Re: Where have all my units gone?
    ... The problem isn't getting it to compile - I've downloaded FreePascal and was able to compile it with only a few adjustments. ... The problem is in getting it to run under Windows 2000, ... Most probably because of the amount of assembler code inside:( ... driver Kit and MS VC compiler, ...
    (alt.comp.lang.borland-delphi)
  • Linker error in call from C to ASM
    ... I have a programming problem over here... ... also lookes like he does not compile the ASM correctly so I used TASM ... in my command prompt to compile the ASM file and than added the OBJ ... _wtty -- put a character to the video display using WTTY call ...
    (comp.lang.c)
  • Re: Help! The problem about armasm.exe
    ... What we want to do is manually optimizing the code. ... modify a few instructions in the intermedial asm file. ... Then I use armasm.exe to compile the .asm. ... Can you tell me why your assembler can't assemble the .asm files generated ...
    (microsoft.public.windowsce.embedded.vc)