assembly

x86 Assemby Language programming on windows XP.

I am facing extreme difficulty digesting the concepts of assembly language programming. I am reading the book of Barry B Brey. Please tell me if there is any good online tutorial and free Assembler Programming Tool very easy to begin with. ...

Defining a variable inside c++ inline assembly

Let's say we have the following c++ code: int var1; __asm { mov var1, 2; } Now, what I'd like to know is if I didn't want to define var1 outside the __asm directive, what would I have to do to put it inside it. Is it even possible? Thanks ...

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 ...

Inline Assembly Jump Error

Why does this fail, once Masm reaches jmp? struct gdt_entry { unsigned short limit_low; unsigned short base_low; unsigned char base_middle; unsigned char access; unsigned char granularity; unsigned char base_high; }; struct gdt_ptr { unsigned short limit; unsigned int base; }; struct gdt_entry gdt[3]; s...

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...

Disable EXCEPTION_DEBUG_EVENT from being passed to an attached debugger

I'm dealing with an anti-debug application which disables EXCEPTION_DEBUG_EVENT from being passed to my debugger, instead it executes its SEH and UnhandledExceptionFilters. I tried it with 3 different debuggers (even selfmade one) My debugger receives other debug events like LOAD_DLL, CREATE_THREAD etc Exceptions are not passed when fi...

Bytecode instrumentation generating java verifier error

Hi, I am using ASM in order to do bytecode instrumentation for Java programs. What I'm doing is simple - When instrumenting a method, if the instruction is a PUTFIELD, simply do a DUP_X1 right before the instruction, then visit the PUTFIELD and inject a function call with an argument that includes the DUP'ed stack entry. ...

Problem with mips assembly

I have aproblem with my mips port....Whenever i try to compile a C program with a printf statement it gives a warning saying it is not recognized and in the generated assemble file there is no .asciiz directive...The string is not there....can anyone please tell me why?? And also what is the difference in between building a bare metal c...

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...

Is it correct to assume that the initial value of a local variable is zero?

If I have a call procedure on asm: push ebp mov ebp esp sub ebp, 8 Can I assume right now that both [ebp-4] and [ebp-8] are initialized to zero, or can they have random values? ...

What is wrong with this simple piece of code?

I have the following piece of code, which should at the breakpoint show 123 at eax and 321 at ecx. For some reason that is not happening. Anyone cares to explain why? push ebp; mov ebp, esp; sub esp, 8; mov [ebp-4], 123; mov [ebp-8], 321; mov eax, [ebp-4]; mov ecx, [ebp-8]; pop ebp; <------------- breakpoint here retn; I gues...

Is optimizing certain functions with Assembler in a C/C++ program really worth it?

In certain areas of development such as game development, real time systems, etc., it is important to have a fast and optimized program. On the other side, modern compilers do a lot of optimization already and optimizing in Assembly can be time consuming in a world where deadlines are a factor to take into consideration. Questions: I...

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 ...

Programming Environment for a Motorola 68000 in Linux

Greetings all, I am taking a Structure and Application of Microcomputers course this semester and we're programming with the Motorola 68000 series CPU/board. The course syllabus suggests running something like Easy68K or Teesside Motorola 68000 Assembler/Emulator at home to test our programs. I told my prof I run x64 Linux and asked wh...

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...

Cygwin gcc - asm error:

I have a project written in C that originally was being done on Linux, but now must be done on Windows. Part of the code include this line in several places asm("movl temp, %esp"); But that causes an "undefined reference to `temp'" error. This has no problem compiling on Linux using the gcc 4.3.2 compiler (tested on another machine)...