x86

Visual Studio 2008 sp1 vc++ project works in 32 bit mode, but not 64 bit

I have a project that runs perfectly well under windows 7, x86 installation. On the same machine, but in a different drive, I've installed windows 7, x64, and visual studio 2008 sp1 on both. The project compiles and runs under win32. When I try to compile the project under x64, I get nothing, and everything gets 'skipped'. Furthermor...

GCC's assembly output of an empty program on x86, win32

I write empty programs to annoy the hell out of stackoverflow coders, NOT. I am just exploring the gnu toolchain. Now the following might be too deep for me, but to continuie the empty program saga I have started to examine the output of the C compiler, the stuff GNU as consumes. gcc version 4.4.0 (TDM-1 mingw32) test.c: int main() ...

Which syntax and architecture of assembly is most useful to know?

I've always wanted to learn assembly, but there seems to be a jungle of assembly-related information out there that is difficult to interpret. I haven't just been able to google "learn assembly" and get going. First, there are two types of syntax: Intel and AT&T. What's the difference? Why are there still two in use? When would I ne...

Inline assembly error, thwarting gcc compilation attempts.

Greetings, SO. I have some code which I've made attempts at compiling using gcc, but my attempts have been thwarted. Could anyone more versed assist me with the subject, perhaps there's something I'm missing. I'm compiling this code on Linux Kitchen 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 x86_64 GNU/Linux. int ...

Using C with inline assembler beginner problem

Hello! I am just testing and trying to learn how assembler works with C. So i was browsing around some tutorials and i found this: __asm { mov ax,0B800h //startaddress for the screen memory (in textmode) mov es,ax //add the startaddress to es xor di,di //reset di (start at the beginnin...

Explanation of Asm code

Hi, The following GCC inline asm is taken from LuaJit's coco library. Can someone provide a line by line explanation of what it does? static inline void coco_switch(coco_ctx from, coco_ctx to) { __asm__ __volatile__ ( "movl $1f, (%0)\n\t" "movl %%esp, 4(%0)\n\t" "movl %%ebp, 8(%0)\n\t" "movl 8(%1), %%ebp\n\t" "...

Any reason to do a "xor eax, eax"?

xor eax, eax will always set eax to zero, right? So, why does MSVC++ sometimes put it in my executable's code? Is it more efficient that mov eax, 0? 012B1002 in al,dx 012B1003 push ecx int i = 5; 012B1004 mov dword ptr [i],5 return 0; 012B100B xor eax,eax Also, what does it mean to do in...

ret, retn, retf - how to use them

I have the following asm code: ; int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) _wWinMain@16 proc near var_8= dword ptr -8 var_4= dword ptr -4 hInstance= dword ptr 8 hPrevInstance= dword ptr 0Ch lpCmdLine= dword ptr 10h nShowCmd= dword ptr 14h push ebp mov ebp, esp sub ...

Disposition of pushed arguments in memory

; int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) _wWinMain@16 proc near var_8= dword ptr -8 var_4= dword ptr -4 hInstance= dword ptr 8 hPrevInstance= dword ptr 12 lpCmdLine= dword ptr 16 nShowCmd= dword ptr 20 If I have a dword variable on [ebp+4], does it mean the variable...

What is the size of each asm instruction?

What is the size of each asm instruction? Every instruction takes how many bytes? 8 bytes? Four for the opcode and Four for the argument? What happens when you have one opcode and 2 arguments, in mov, for example? Do they have a fixed size in memory or do they vary? Does EIP have anything to do with this, of its value is always increment...

A few x86 Assembly language questions...

I've just started using assembly language (felt like learning something new), and have run into a few questions (so far) that all the tutorials I've been looking through don't answer, or are too old to know. 1) I've tried a few searches (maybe I just don't know the right keywords), but I can't find an updated list of graphics modes for ...

Flags registers - Can we read or write them directly?

From what I've read, seems like there are 9 different flags. Is it possible to read/change them directly? I know I can know for example if the zero flag is set after doing a cmp/jmp instruction, but I'm asking if it's possible to do something like mov eax, flags or something. Also, for writting, is it possible to set them by hand? T...

How would I go about creating my own VM ?

I'm wondering how to create a minimal virtual machine that'll be modeled after the Intel 16 bit system. This would be my first actual C project, most of my code is 100 lines or less, but I have the core fundamentals down, read K&R, and understand how things ought to work, so this pretty much is a test of wits. Could anyone guide me in ...

Lightweight x86 Emulator for .NET / Executing x86 code in a managed environment

Our company is migrating its entire product line from a C++ codebase to the .NET Framework. We have a very large codebase, and this migration is being done incrementally over the course of many years. We would like to enjoy some of the benefits of pure managed code, such as Silverlight, but there are many legacy C++/x86 modules that wi...

DOS Interrupt in masm x86 assembly crashing

I've just begun learning some x86 assembly on win32, and I've used masm with visual studio 2008 using the custom build rule that comes with the ide for .asm files. I've been trying to use the DOS interrupt to print to the console, but instead I receive the message: "Unhandled exception at 0x00401004 in ASMTest.exe: 0xC0000005: Access vio...

Intel x86 assembly optimization techniques in a sample problem.

I am learning assembler quite a while and I am trying to rewrite some simple procedures \ functions to it to see performance benefits (if any). My main development tool is Delphi 2007 and first examples will be in that language but they can be easily translated to other languages as well. The problem states as: We have given an unsigne...

alignment requirements for atomic x86 instructions

Microsoft offers the InterlockedCompareExchange function for performing atomic compare-and-swap operations. There is also an _InterlockedCompareExchange intrinsic. On x86 these are implemented using the cmpxchg instruction. However, reading through the documentation on these three approaches, they don't seem to agree on the alignment r...

x86 Assembly, misleading Error

I am trying to learn assembly, and have a program in AT&T syntax, for use with GNU AS Which I believe should work. I receive this error with GDB: Program received signal SIGSEGV, Segmentation fault. .PROGRAM () at concatenator.s:60 60 call strlen Current language: auto; currently asm The code is: .file "concatenator....

Configure ASP.NET to use x86 on x64 Windows

I am trying to deploy GAL Modifier, which is an ASP.NET website which uses Microsoft Access on a Windows 2003 x64 machine. However there is no JET driver on x64 (see here), so the change is to use change the target CPU to x86. However as it is a web site there is no option in Visual Studio except Any CPU, so how can I change the settin...

Is there a caching penalty for mixing binary data and instructions within close proximity of each other?

I'm procedurally generating 128-byte blocks with some set n-byte header reserved for machine-language functions that I'm simply calling via in-line assembly. They aren't defined anywhere and are generated at run-time into pages allocated into memory with access for execution. However, I want to reserve the end (128 - n) bytes of these ...