x86

Detect another process's bitness (in Windows)

How can I detect whether another process is running as 32/64 bit in Windows? I know how to do this for my own process, but not for a different process. A tip or solution in any language would be fine. Thanks! ...

When is the ASID in AMD's page table extensions no longer valid?

IA-32 defines various cases in which the CPU may invalidate the entire TLB. Starting with the ASID extensions that AMD released in Opteron Rev-F processors (Barcelona?) there are cases in which only the TLB entries of a certain ASID are invalidated. The question is, does the ASID itself ever stop being valid? Does the Hypervisor hav...

Order of local variable allocation on the stack

Take a look at these two functions: void function1() { int x; int y; int z; int *ret; } void function2() { char buffer1[4]; char buffer2[4]; char buffer3[4]; int *ret; } If I break at function1() in gdb, and print the addresses of the variables, I get this: (gdb) p &x $1 = (int *) 0xbffff380 (gdb) p...

Resources for x86 compiler backend

I am writing a Tiger compiler in F# and I have decided to emit x86 assembly. I know the basics of how a machine is constructed and also a bit of assembly, but not enough to write a good compiler back-end. What resources can you recommend for learning what I need to know? Where can I look up information such as calling conventions, etc....

How do you multiply two 64-bit numbers in x86 assembler?

Possible Duplicate: How can I multiply two 64bit numbers using x86 assembly language? How do you multiply two 64-bit numbers in x86 assembler? This question is important for historical reasons. Presumably, Joel meant 386 assembler. Related question How do you multiply two 64bit numbers in assembly ...

Does using xor reg, reg give advantage over mov reg, 0?

There're two well-known ways to set an integer register to zero value on x86. Either mov reg, 0 or xor reg, reg There's an opinion that the second variant is better since the value 0 is not stored in the code and that saves several bytes of produced machine code. This is definitely good - less instruction cache is used and this ca...

What's the relative speed of floating point add vs. floating point multiply

A decade or two ago, it was worthwhile to write numerical code to avoid using multiplies and divides and use addition and subtraction instead. A good example is using forward differences to evaluate a polynomial curve instead of computing the polynomial directly. Is this still the case, or have modern computer architectures advanced t...

trying to understand the main disassembly first instructions

hi I have disassembled some programs (linux) I wrote to understand better how it works, and I noticed that the main function always begins with: lea ecx,[esp+0x4] ; I assume this is for getting the adress of the first argument of the main...why ? and esp,0xfffffff0 ; ??? is the compiler trying to align the stack pointer on 16 byte...

x86 equivalent for LWARX and STWCX

I'm looking for an equivalent of LWARX and STWCX (as found on the PowerPC processors) or a way to implement similar functionality on the x86 platform. Also, where would be the best place to find out about such things (i.e. good articles/web sites/forums for lock/wait-free programing). Edit I think I might need to give more details as ...

How does an OS affect how assembly code runs?

I'm hoping to learn assembly language for x86. I'm on a Mac, and I'm assuming most x86 tutorials/books use code that's meant for Windows. How does the OS that code is run on affect what the code does, or determine whether the code even works? Could I follow a Windows-based tutorial, and modify a few commands to make it work for Mac wi...

80x86 assembly question

I have this code : section .data Foos: mov ecx,7 mov edx,5 L: inc edx sub ecx,1 setZ al ; set al to 1 if zero flag, otherwise al=0 shl al,1 mov byte[L1+1],al L1: jmp L lmp L mov eax,edx ret The question is what will be in eax at the end of the code? I don't know why the answer is 12? ...

why is the call stack set up like this?

I was just playing with the call stack, trying to change the return address of a function etc, and wound up writing this program in C: #include<stdio.h> void trace(int); void func3(int); void func2(int); void func1(int); int main(){ int a = 0xAAAA1111; func1(0xFCFCFC01); return 0; } void func1(int a){ int loc = 0...

how do procedure calls work in assembler?

I just started tinkering with ASM and I'm not sure if my understanding of procedure calls is correct. say at some point in the code there is a procedure call call dword ptr[123] and the procedure consists of only one command, ret: ret 0004 what would be the effect of this procedure call, and where would the return value be stored?...

Assembly code for sin(x)

Hi could you please give me a assembly code for calculate sin(x)[using:"Taylor Expansion"] in linux? With Best Wishes ...

Basic questions about Assembly and Macs

Okay. I want to learn how to assemble programs on my Mac (Early 2009 MBP, Intel Core 2 Duo). So far, I understand only that Assembly languages are comprised of direct one-to-one mnemonics for CPU instructions. After some Googling, I've seen a lot of terms, mostly "x86" and "x86_64". I've also seen MASM, NASM, and GAS, among others. Corr...

Including references from x86 or "Any CPU" to other assemblies in Visual Studio 2008

It seems that if I have a .NET assembly that is going to be loaded by some unmanaged "x86" code, running on a 64bit O/S (e.g. Vista), then I need to compile that .NET assembly with the .x86 Solution Platform. What about other .NET assemblies that my original assembly references? Are they allowed to be "Any CPU" assemblies? Or must the...

How can I load values from memory without polluting the cache?

Hello, I want to read a memory location without polluting the cache. I am working on X86 Linux machine. I tried using MOVNTDQA assembler instruction: asm("movntdqa %[source], %[dest] \n\t" : [dest] "=x" (my_var) : [source] "m" (my_mem[0]) : "memory"); my_mem is an int* allocated with new, my_var is an int. I have two problem...

What is this x86 inline assembly doing?

I came across this code and need to understand what it is doing. It just seems to be declaring two bytes and then doing nothing... uint64_t x; __asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (x)); Thanks! ...

How can I know if a dll is x86, x64 or any architecture?

Possible Duplicate: How to determine if .NET assembly was built for x86 or x64? How can I know if a .Net DLL was compiled for x86, x64 or any architecture? ...

Dereferencing a label in x86 assembly

Consider this x86 assembly code: section .data foo: mov ebx, [boo] mov [goo], ebx goo: mov eax, 2 mov eax, 3 ret boo: mov eax, 4 mov eax, 5 ret What exactly is going on here? When I dereference [boo] and mov it to [goo] what exactly am I moving there? Just one command? The ret as well? Follow-up que...