After searching for how to use inline assembly with Dev-C++ i fig'd i would share my code
This takes 2 const chars and swaps them thru inline AT&T assembly
The variable booga starts as booga booga and ends up as JMC31337

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
char *booga="BOOGA BOOGA";
char *booga2="JMC31337";
void swap()
{
asm
(
"movl %1, %0" //mov %1(booga2 -> %0(booga)
: "=r"(booga) //store -> booga
: "r"(booga2), "r"(booga) //(src) -> (dst)
);
cout<<booga;
}
int main()
{
    cout<<"Testing Assembly\n";
    cout<<booga<<" THRU C++\n";
    cout<<"IS NOW ";
    swap();
    cout<<" SWAPPED THRU ASM";
    getchar();
    return 0;   
}

Recommended Answers

All 2 Replies

Since there is no question, should this be moved to "code snippets"?

i didnt know.. my apologies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.