assembly

How can I determine the location of disassembled code within an executable?

Hi all, I've got an executable file (C++, i386, compiled under MacOS/X Tiger, if it matters) that contains a bug. The fix for the bug is straightforward -- there's a place in the code where it calls fork() and it shouldn't. Because the fix is simple, and because recompiling the executable from scratch would be difficult at this point ...

What is the best way to go about writing a simple x86 assembler?

I'm interested in writing an x86 assembler for a hobby project. At first it seemed fairly straight forward to me but the more I read into it, the more unanswered questions I find myself having. I'm not totally inexperienced: I've used MIPs assembly a fair amount and I've written a toy compiler for a subset of C in school. My goal is...

Memory adressing in asm

Hi, I'm learning asm and here's one of my (many) problems : I'd like to change the value of some index of an array. Let's say that : %eax contains my new value the top of the stack (ie (0)%esp) contains the index of the array -4(%ebp) contains the adress of the array. I've tried movl %eax, (-4(%ebp),0(%esp),4) but it did not work. ...

C inline assembly memory copy

I am trying to write some inline assembly into C. I have two arrays as input, what I need is to copy one element in array1 into array2, and the following is what I have at the moment: asm ( "movl %0,%%eax;" "movl %1,%%ebx;" "movl (%%eax),%%ecx;" "movl %%ecx,(%ebx);" "xor %%ecx,%%ecx;" "movl 4(%%eax),%%ecx;" //do something on %ecx...

Examining code generated by the Visual Studio C++ compiler, part 1

Background I'm just learning x86 asm by examining the binary code generated by the compiler. Code compiled using the C++ compiler in Visual Studio 2010 beta 2. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.21003.01 for 80x86 C code (sandbox.c) int mainCRTStartup() { int x=5;int y=1024; while(x) { x--; y/=2; }...

x86 asm: What's the purpose of the LEA instruction?

For me, it just seems like a funky MOV. What's its purpose and when should I use it? ...

Where does at&t assembly syntax come from?

Intel makes microprocessor, so he could define the instruction format and its corresponse assembly of its processors,so why AT&T could also create its syntax of assembly language? thanks. ...

CPUID implementations in C++

Hi, I would like to know if somebody around here has some good examples of a C++ CPUID implementation that can be referenced from any of the managed .net languages. Also, should this not be the case, should I be aware of certain implementation differences between X86 and X64? I would like to use CPUID to get info on the machine my sof...

What does OFFSET in 16 bit assembly code mean?

I am going through some example assembly code for 16bit real mode. I've come across the lines: mov bx, cs mov ds, bx mov si, OFFSET value1 pop es mov di, OFFSET value2 what is this doing? What does having 'OFFSET' there do? Sorry if its a very basic question, i'm new at this. ...

Compiling assembly for X86/X64 for use with C#

I would like to add cpuid functionality to my C# app. I found this interesting blog post online. I will probably need MASM to compile this but: How should I start? I suspect that I will have to compile a dll for both X86 and X64 but again I don't have a clue about how to go about such a thing (and I am a bit pressed for time). So any...

What does %c mean in GCC inline assembly code?

I am trying to understand this inline assembly code which comes from _hypercall0 here. asm volatile ("call hypercall_page+%c[offset]" \ : "=r" (__res) \ : [offset] "i" (__HYPERVISOR_##name * sizeof(hypercall_page[0])) \ : "memory", "edi", "esi", "edx", "ecx", "ebx", "eax") I am having trouble finding informatio...

LNK4086 warning and missing dll entrypoint in VS2008 asm build

I tried to compile the following .asm file in VS2008 (as part of an empty Win32 dll project to which I added this single .asm file): .386 .model flat, stdcall option casemap:none TRUE equ 1 .code start: DllEntry proc instance:DWORD, reason:DWORD, reserved:DWORD mov eax, TRUE ret DllEntry endp CPUIDI...

Problem with output, doesn't read jump...

.section .data msgI: .ascii "x = y\n" msgI_end: msgM: .ascii "x > y\n" msgM_end: msgL: .ascii "x < y\n" msgL_end: .section .text .globl main main: movl $5, %eax #x = 5 movl $5, %ebx #y = 10 cmp %ebx, %eax je IGUAL jg MAYOR jl MENOR IGUAL: #Esta seccion de cogido se ...

MIPS Syscalls and $t registers

MIPS registers have a convention - $s registers are to be preserved across subroutine calls, so if your subroutine modifies them, it should save them to the stack, while $t registers are not preserved. Now, can a syscall potentially modify a $t register? In a simulator I have, it doesn't, but could a real machine have the $t registers c...

write message to screen in AT&T assembly

I'm attemping to write my own bootloader and i'm having issues with writing to the screen. I've found examples using interrupts: ; --------------------------------------------------------- ; Main program ; --------------------------------------------------------- mov si, msg ; Print message call putstr hang...

ljmp syntax in gcc inline assembly

I was thinking of using a far jump to set the code segment (CS) register. Getting into why I'm doing this and why I'm dealing with segmentation at all would take a while, so bear with me and consider it an academic exercise. I can't seem to get the syntax right. Error: suffix or operands invalid for 'ljmp' I know it's foolish to put c...

Decrypt file using XOR

First I'm using MASM, I'm opening an encrypted file and putting it's contents into a buffer and exporting it to a new file. I have everything working except the decrypting portion. I'm not sure if I need to XOR the buffer itself or do I reference edx (where I store the buffer), or do I need to XOR the bytes read which I put in the eax r...

Translate a FOR to assembler

Hi everyone, I need to translate what is commented within the method, to assembler. I have a roughly idea, but can't. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, EXPRESION * * o ) { int a, i; //--- Translate from here ... for ( i = 0; i < n; i++ ){ a = evaluarExpresion( *o ); o++; ...

Simple Increment in assembler

Hi, I'm stuck with this. I'm self studying assenbler and translating some basics instructions. But i can't with this one. Can anyone help me, please? int secuencia ( int n, EXPRESION * * o ) { int a, i; for ( i = 0; i < n; i++ ){ a = evaluarExpresion( *o ); // Im trying to do this: o++; __asm { mov eax,dword ptr [...

Does anyone know where to get actual Cray PVP code?

I want to write a emulator for one of the older Crays, but I've run into a stumbling block. I can't seem to find any actual code for them. (Which kind of makes sense I suppose, most of them would have been used for defense and the like..) Does anyone know where I might find something? Binaries or source, it's all good. The thing I'd...