Skip to main content
gamedev.net
🔒 Locked

what's wrong?

Started by jmg5 Feb 1, 2004 at 6:12 PM 8 replies 600+ views
Original Post
jmg5
jmg5
int x, y;

main(){
    x = 5;
    y = x;
    
    asm{
        "mov _x, %dx\n"
        "mov _y, %ax\n"
        "add %ax, %dx\n"
        "mov %dx, _x"
    };
    
    return x;
}
 
Why is there a parse error? My error says there''s a parse error before the "{" after "asm". This was just a test, but I can''t figure out why it won''t work.
SiCrane
SiCrane
What compiler is this? You could be using the wrong assembly notation for your compiler.
jmg5
jmg5
I''m just messing around with Dev-C++. I really have no idea if it''s the right notation.
Mathematix
Mathematix
All I can say is that this is completely wrong assembly. You should do:


asm{
mov ax, 0x0005
mov bx, ax
add ax, 0x0005
mov dx, ax
}

This is as far as I understand from your code. I hope this gives you some idea.

[edited by - mathematix on February 2, 2004 9:00:01 AM]
sBibi
sBibi
Mathematix:

quote:
All I can say is that this is completely wrong assembly. You should do:


well, all you can say is wrong, this is not completely wrong assembly. all compilers on earth are not VC++ and do not necessarily use intel''s asm syntax (although I really prefer intel''s syntax), that syntax looks like GNU asm syntax (AT&T?), the one used in GCC.

jmg5 > replace the opening and closing braces by parenthesis. (assuming DevC++ uses the gnu asm syntax)
Mathematix
Mathematix
quote:
Original post by sBibi
Mathematix:

quote:
All I can say is that this is completely wrong assembly. You should do:


well, all you can say is wrong, this is not completely wrong assembly. all compilers on earth are not VC++ and do not necessarily use intel''s asm syntax (although I really prefer intel''s syntax), that syntax looks like GNU asm syntax (AT&T?), the one used in GCC.

jmg5 > replace the opening and closing braces by parenthesis. (assuming DevC++ uses the gnu asm syntax)

All I can say is, sBibi, on reading the original post I didn''t kow what the hell I was doing.

jmg5
jmg5
quote:

Sorry, but that''s just stupid (and I''m being nice). So you''re just guessing the notation and can''t figure why it won''t work. Well, the compiler is not a oracle who can understand every imaginary syntax you input to it. I hope this is a joke.



No, it wasn''t a joke. I was using gnu syntax (and i''m not quite familiar with it, as you can tell) and figured it''d be the same, but wasn''t quite sure.

sBibi, thanks. I replaced ''em with parentheses and it worked.
Deranged
Deranged
quote:
Original post by Mathematix
All I can say is that this is completely wrong assembly. You should do:


asm{
mov ax, 0x0005
mov bx, ax
add ax, 0x0005
mov dx, ax
}

This is as far as I understand from your code. I hope this gives you some idea.

[edited by - mathematix on February 2, 2004 9:00:01 AM]


dev-C++ uses AT&T not INTEL. OH and the command for ASM in DEv-C++ is __asm thats 2 underscores

TAKEN FROM THE DEV-C++ FAQ!1~

How to use assembly with Dev-C++ ?
The "GNU as" assembler uses AT&T syntax (not Intel). Check out this page for more information.
Here's an example of such a syntax :

// 2 global variables

int AdrIO;
static char ValIO;

void MyFunction(..........)
{
__asm("mov _AdrIO, %dx") ; // loading 16 bits register

__asm("mov _ValIO, %al") ; // loading 8 bits register

/*
Don't forget the underscore _ before each global variable names !
*/

__asm("mov %ax,%dx") ; // AX --> DX

}






[edited by - DerAngeD on February 2, 2004 5:56:44 PM]
Mathematix
Mathematix
quote:
Original post by DerAnged
quote:
Original post by Mathematix
All I can say is that this is completely wrong assembly. You should do:


asm{
mov ax, 0x0005
mov bx, ax
add ax, 0x0005
mov dx, ax
}

This is as far as I understand from your code. I hope this gives you some idea.

[edited by - mathematix on February 2, 2004 9:00:01 AM]

dev-C++ uses AT&T not INTEL. OH and the command for ASM in DEv-C++ is __asm thats 2 underscores

TAKEN FROM THE DEV-C++ FAQ!1~

How to use assembly with Dev-C++ ?
The "GNU as" assembler uses AT&T syntax (not Intel). Check out this page for more information.
Here's an example of such a syntax :

// 2 global variables

int AdrIO;
static char ValIO;

void MyFunction(..........)
{
__asm("mov _AdrIO, %dx") ; // loading 16 bits register

__asm("mov _ValIO, %al") ; // loading 8 bits register

/*
Don't forget the underscore _ before each global variable names !
*/

__asm("mov %ax,%dx") ; // AX --> DX

}






[edited by - DerAngeD on February 2, 2004 5:56:44 PM]

Yes, you're right.


[edited by - mathematix on February 2, 2004 7:14:55 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.