inline-assembly

Generating random numbers with ARM Assembly

hi , i want to generate random number to use it in my iphone project by Inlining in my objective-c code some assembly , is this possible with arm-assembly ?! Thank you to help .. ...

Why Inline asm in C++/CLI creates horrible problem?

Hello, I am using Inline asm in C++/CLI. Horrible problem infact could be a bug I obsereved. I passed vector from one function call to another. If I comment the whole code snippet of _asm{....some assembly code here} inside the called function where vector used which are provided to it from other function, then no problem whole vector...

C++ inline assembly function not working properly

I get a different return value each time, so I'm doing something wrong. If I replace the add with a basic inc, it returns correctly. Here is the code. #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <iostream> using namespace std; int Add ( int _Number1, int _Number2 ); int main ( int _ArgumentCount, char * _Arguments[] )...

What's use of %c in x86_64 inline assembly?

I'm reading KVM source code and confronted with x86_64 inline assembly. In the following code, what's use of "%c"? It it new feature in x86_64 inline assembly? Any reference for new features in x86_64 inline assembly in gcc? Many thanks /* Check if vmlaunch of vmresume is needed */ "cmp $0, %1 \n\t" /* Load guest registers....

Using ASM when compiling x64 C++ with MSVC10

Due to MSVC10 not allowing the use of inline ASM instructions when targeting x64 architecture, I'm looking for any ways to get around such restrictions. I have learned from googling that writing and compiling separate ASM modules then linking against them and calling them from C++ is one way, however I have no idea how I would do this. A...

MessageBoxA in Windows AT&T Assembly

Hi guys, I'm trying to call MessageBoxA() directly in assembly, using gcc inline. However I need to do this in 2 ways: first is using dynamic addressing, with LoadLibrary() and GetProcAddress() - I found a tutorial about this, trying to follow it. But I'm also interested in calling directly the address of MessageBoxA, wich is 0x7e4507ea...

Inline Assembly: Passing pointers to a function and using it in that function in assembly

Guys, I'm using ARM/Cortex-A8 processor platform. I have a simple function where I have to pass two pointers to a function. These pointers are later used in that function which has only my inline assembly code This plan is only to achieve performance. function(unsigned char *input, unsigned char *output) { // What are the assembl...

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

sse inline assembly with g++

I'm trying out g++ inline assembly and sse and wrote a first program. It segfaults - why? #include <stdio.h> float s[128*4] __attribute__((aligned(16))); #define r0 3 #define r1 17 #define r2 110 #define rs0 "3" #define rs1 "17" #define rs2 "110" int main () { s[r0*4+0] = 2.0; s[r0*4+1] = 3.0; s[r0*4+2] = 4.0; s[r0*4+3] = 5.0; ...

Is there a way to use expressions evaluated at compile-time with inline asm in gcc?

I have some code that basically needs to use a small expression in an assembly statement, where the expression is fairly trivial like i*4, but GCC doesn't seem to realize that at compile time (tried no -O flag, and -O3). Neither "i" nor "n" constraints work in the following snippet for the third usage. #include <stdint.h> #include <st...

Type in inline assembly

In some code I was writing, I had the following line: __asm mov [ebp-24], 0 ...from which the compiler generated mov BYTE PTR [ebp-24], 0 Is there any way I can make it generate mov DWORD PTR [ebp-24], 0 instead? ...

Win32 Low Level Assembly

Hi guys, do you know where I can find Windows Low Level Assembly examples programs? I have some exemples using macros (NASM, MASM) but I want pure assembly, in order I can build a shellcode later. Thanks a lot guys! ...

How to generify data for "mov" instruction ?

Hello, I need to understand just 1 single instruction and accordingly I need to generify the things. I need to pass structures (Objects of User Defined Data Types) at runtime using following assembly code. Where Following is User Defined Data Type namely WESContext : typedef struct CWESContext { BSTR UserName; BSTR Mach...

Basic GCC inline assembly question

I want to move the value of the variable "userstack" inside the ESP register and then do an absolute jump to the memory address contained in the variable "location". This is what I've got: // These are the two variables that contains memory addresses uint32_t location = current_running->LOCATION; uint32_t userstack = current_running->...

Complicated code for obvious operations

Hi, Sometimes, mainly for optimization purposes, very simple operations are implemented as complicated and clumsy code. One example is this integer initialization function: void assign( int* arg ) { __asm__ __volatile__ ( "mov %%eax, %0" : "=m" (*arg)); } Then: int a; assign ( &a ); But actually I don't understand why is it w...

GCC Inline Assembly Multiplication

I'm trying to learn GCC inline assembly on Linux (x86), and my first experiment was to try and implement integer overflow detection for multiplication. It seems easy enough, but it is having side effects which I don't understand. So, here I want to multiply two unsigned 8-bit integers, and see if the result overflows. Basically I just...

Labels in GCC inline assembly

In my ongoing experimentation with GCC inline assembly, I've run into a new problem regarding labels and inlined code. Consider the following simple jump: __asm__ ( "jmp out;" "out:;" : : ); This does nothing except jump to the out label. As is, this code compiles fine. But if you place it inside a function, and the...

GCC inline assembly: constraints

I'm having difficulty understanding the role constraints play in GCC inline assembly (x86). I've read the manual, which explains exactly what each constraint does. The problem is that even though I understand what each constraint does, I have very little understanding of why you would use one constraint over another, or what the implic...

x86 Assembly: INC and DEC instruction and overflow flag

In x86 assembly, the overflow flag is set when an add or sub operation on a signed integer overflows, and the carry flag is set when an operation on an unsigned integer overflows. However, when it comes to the inc and dec instructions, the situation seems to be somewhat different. According to this website, the inc instruction does not...

inline assembly output register declaration

Hi! i'm just about to learn inline assembly.the GCC inline assembly cookbook http://www.ethernut.de/en/documents/arm-inline-asm.html says: A strict rule is: Never ever write to an input operand. can someone tell me whether - and if so why - this rule is true? let's say i get the value of an input operand through some register. Am I ...