assembly

How to return a complex return value?

Hi awesomes~ Currently I am writing some assembly language procedures. As some convention says, when I want to return some value to the caller, say an integer, I should return it in the EAX register. Now I am wondering what if I want to return a float, a double, an enum, or even a complex struct. How to return these type of values? I c...

In Line Assembly Example

I would like a simple example for how to do the following in in-line assembly, x86, visual studio for (int i=1; i<N; ++i) { // do something } ...

VC++ inline asm syntax error

__asm { mov bl, byte [0x0068F51C] call 0x004523C0 } This code gives this error: main.cpp(57): error C2400: inline assembler syntax error in 'second operand'; found '[' main.cpp(58): error C2415: improper operand type Line 57 is the line with the mov instruction. I don't see what I'm doing wrong here, especially the call instruct...

MIPS programming issue

Hello all. I'm having a MIPS issue here. What I'm trying to do is have the user input any number and have the program spell out the name of each digit in the number. So for example, the user inputs 495 and the machine would spell out "Four Nine Five". I'm trying to push each digit of the number onto the stack, then pop each one off. ...

How does an assembly instruction turn into voltage changes on the CPU?

I've been working in C and CPython for the past 3 - 5 years. Consider that my base of knowledge here. If I were to use an assembly instruction such as MOV AL, 61h to a processor that supported it, what exactly is inside the processor that interprets this code and dispatches it as voltage signals? How would such a simple instruction like...

add vs mul (IA32-Assembly)

I know that add is faster as compared to mul function. I want to know how to go about using add instead of mul in the following code in order to make it more efficient. Sample code: mov eax, [ebp + 8] #eax = x1 mov ecx, [ebp + 12] #ecx = x2 mov edx, [ebp + 16] #e...

Why visual studio recognizes __asm {} but can't recognize assembly code?

We can use stuff like this in visual studio: __asm { mov x1,offset thunk_begin; mov x2,offset thunk_end; } But as quoted from here: Since Visual Studio does not recognize assembly code, Visual Studio will have to be told what program to call to compile the assembly code. I'm really confused. ...

SendMessage lParam empty

I am trying to store a value in the lParam of a LV_ITEM: ;... mov eax, value mov lvi.lParam, eax invoke SendMessage, hList, LVM_INSERTITEM, 0 addr lvi lvi is a (LOCAL) LV_ITEM, and hList is the handle of my ListView Control. If this item is now clicked, i try to read it's value: invoke SendMessage,hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSE...

Defining Bytes in GCC Inline Assembly in Dev-C++(.ascii in AT&T syntax on Windows)

Hey guys, The code below is just showing a Message Box on the screen. The addresses are hardcoded to facilitate: int main () { asm("xorl %eax, %eax \n" "xorl %ebx, %ebx \n" "xorl %ecx, %ecx \n" "xorl %edx, %edx \n" "pushl %ecx \n" //$0x0 "pushl $0x20206...

OTX - Method offset in binary

So I'm dealing with a fat binary, and I'm trying to find the method offset for frame [FOOClass abcdMethod]. Using otool I get the __text segment addr and offset. The only problem is that offset in decimal given in the output equals the starting address of the __text segment. My question is. How can someone deduct the offset of the me...

SSE enhanced libtiff/CCITT Fax4 encoder

Does anyone know of an SSE ehanced version of libtiff? Even just an SSE enhanced version of a CCITT Group4 encoder would do, I could do the work of sliding that one in libtiff myself. I only need to work with bitonal images. Thank you ...

Function Pointers in VS-2010 ( + Virtual Alloc call)

Hi everyone, As an experiment i am trying to write the following program which allows me to generate code during runtime. i.e. i do the following: 1. Fill a buffer with op-codes of the instructions i want to execute. 2. Declare a function-pointer and make it point to the start of the buffer. 3. Call the function using the above func-pt...

Why the output is “In foo, a = 7”?

void foo(int a) { printf ("In foo, a = %d\n", a); } unsigned char code[9]; * ((DWORD *) &code[0]) = 0x042444FF; /* inc dword ptr [esp+4] */ code[4] = 0xe9; /* JMP */ * ((DWORD *) &code[5]) = (DWORD) &foo - (DWORD) &code[0] - 9; void (*pf)(int/* a*/) = (void (*)(int)) &code[0]; pf (6); Anyone knows where in the ab...

Is assembly code cross-platform?

0x042444FF; /* inc dword ptr [esp+4] */ 0x042444FF is the machine code,while inc dword ptr [esp+4] is the assembly code, I know machine code is NOT cross-platform,as it depends on many factors. What about assembly code, does it depends on CPU ? ...

Is there a command line tool to get the machine code for an assembly instruction ?

0x042444FF; /* inc dword ptr [esp+4] */ I need this tool to know which part means inc , dword or vice versa. ...

copy and call function

I'd like to copy and call a function, but the code below segfaults when calling the buffer. What do I have to change? (Linux, x86) #include <string.h> #include <malloc.h> #include <stdio.h> int foo () { return 12; } void foo_end () {} int main () { int s = (unsigned long long) foo_end - (unsigned long long) foo; int (*f) () = (int...

What's so called "Frames" in visual studio?

In the Call Stack window of visual studio, it reports: [Frames below may be incorrect and/or missing, no symbols loaded for IPCamera.ax] What does it mean by Frames, and why missing symbols may cause it incorrect?AFAIK,symbols are just for debugging info,missing symbols will only make the source invisible . ...

Where do I start with assembly?

Hey I can program in C,little bit in Python and Pascal and I really want to learn assembly. I'm 18 and finishing high school, programming is my hobby because school work sure isn't much of a challenge. I've downloaded a few books on Assembly they are: The Art of Assembly,Assembly for Beginners, Assembly for Complete Beginners and Wrox P...

About mov in assembly

move the contents of the register bx into the register ax MOV ax, bx Why is the syntax so strange? Mov ax, (to) bx actually means move contents of bx to ax ,is there any historical reason to define it this way? ...

Anyone knows what "mov edi,edi " does?

69A8AB13 int 3 69A8AB14 int 3 69A8AB15 mov edi,edi 69A8AB17 push ebp 69A8AB18 mov ebp,esp mov edi,edi doesn't make sense for me,what's it for? ...