Jump to content
vladiii

ASM in Dev-C++

Recommended Posts

Posted

Am incercat de foarte multe ori sa scriu coduri ASM in Dev-C++. De fiecare data obtineam mult prea multe erori, asa ca am lasat

balta toata chestia. Ulterior, am aflat ca in Dev-C++ (sau gcc) codurile ASM au o altfel de sintaxa fata de codurile ASM obisnuite.

Si anume, sintaxa AT&T. Nu am reusit [nici nu m-am chinuit] sa o invat. Un mic articol despre aceasta sintaxa gasiti aici:

http://sig9.com/articles/att-syntax.

Azi, navigand pe forumul rohitab (rohitab.com) am descoperit o alternativa la aceasta sintaxa. Noi cand programam ceva in Assembler

folosim defapt sintaxa Intel. Va voi arata exact codul ASM al lui Napalm de pe Rohitab:


#include <stdio.h>
int a;
int main(void)
{
a = 10;
printf("Inainte: a = %d\n", a);
//Urmeaza cod cu sintaxa intel
asm(".intel_syntax noprefix");
//Mutam in eax valoarea variabilei a. De observat underline'ul din fata ei.
asm("mov eax, _a");
//Mutam in ecx valoarea 3
asm("mov ecx, 3");
//Multiplicam eax cu ecx (10 cu 3)
asm("mul ecx");
//Rezultatul stocat in eax il atribuim variabilei a
asm("mov _a, eax");
asm(".att_syntax noprefix");
//Afisam
printf("Dupa: a = %d", a);
return 0;
}

Smecher, nu ?

P.S. Astept completari si de la voi, ca subiectul este foooarte interesant.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...