Jump to content

Problems With C++ And Asm


Recommended Posts

Well, I put -masm=intel in the C++ Compiler box for the linker... put in the .intel_syntax noprefix at the start of the code...

 

Still getting errors.

 

 

Anybody mind telling me what's wrong?

 

#include <iostream>

using namespace std;


bool i = false;

int main()

{
    while(i=false) {
        
    asm(".intel_syntax noprefix \


mov eax,9999\
mov ebx,9999\
mov edx,9999\

mov ecx,1\

add al,al\
add ah,al\
add ah,ah\
add ax,al\
add ax,ah\
add ax,ax\
add eax,al\
add eax,ah\
add eax,ax\
add eax,eax\


mov eax,9999\
mov ebx,9999\
mov edx,9999\

add al,bl\
add ah,bl\
add ah,bh\
add ax,bl\
add ax,bh\
add ax,bx\
add eax,bl\
add eax,bh\
add eax,bx\
add eax,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

add al,dl\
add ah,dl\
add ah,dh\
add ax,dl\
add ax,dh\
add ax,dx\
add eax,dl\
add eax,dh\
add eax,dx\
add eax,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



add bl,al\
add bh,al\
add bh,ah\
add bx,al\
add bx,ah\
add bx,ax\
add ebx,al\
add ebx,ah\
add ebx,ax\
add ebx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

add bl,bl\
add bh,bl\
add bh,bh\
add bx,bl\
add bx,bh\
add bx,bx\
add ebx,bl\
add ebx,bh\
add ebx,bx\
add ebx,ebx\


mov eax,9999\
mov ebx,9999\
mov edx,9999\


add bl,dl\
add bh,dl\
add bh,dh\
add bx,dl\
add bx,dh\
add bx,dx\
add ebx,dl\
add ebx,dh\
add ebx,dx\
add ebx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



add dl,al\
add dh,al\
add dh,ah\
add dx,al\
add dx,ah\
add dx,ax\
add edx,al\
add edx,ah\
add edx,ax\
add edx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


add dl,bl\
add dh,bl\
add dh,bh\
add dx,bl\
add dx,bh\
add dx,bx\
add edx,bl\
add edx,bh\
add edx,bx\
add edx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


add dl,dl\
add dh,dl\
add dh,dh\
add dx,dl\
add dx,dh\
add dx,dx\
add edx,dl\
add edx,dh\
add edx,dx\
add edx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\




sub al,al\
sub ah,al\
sub ah,ah\
sub ax,al\
sub ax,ah\
sub ax,ax\
sub eax,al\
sub eax,ah\
sub eax,ax\
sub eax,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


sub al,bl\
sub ah,bl\
sub ah,bh\
sub ax,bl\
sub ax,bh\
sub ax,bx\
sub eax,bl\
sub eax,bh\
sub eax,bx\
sub eax,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

sub al,dl\
sub ah,dl\
sub ah,dh\
sub ax,dl\
sub ax,dh\
sub ax,dx\
sub eax,dl\
sub eax,dh\
sub eax,dx\
sub eax,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


sub bl,al\
sub bh,al\
sub bh,ah\
sub bx,al\
sub bx,ah\
sub bx,ax\
sub ebx,al\
sub ebx,ah\
sub ebx,ax\
sub ebx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


sub bl,bl\
sub bh,bl\
sub bh,bh\
sub bx,bl\
sub bx,bh\
sub bx,bx\
sub ebx,bl\
sub ebx,bh\
sub ebx,bx\
sub ebx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

sub bl,dl\
sub bh,dl\
sub bh,dh\
sub bx,dl\
sub bx,dh\
sub bx,dx\
sub ebx,dl\
sub ebx,dh\
sub ebx,dx\
sub ebx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



sub dl,al\
sub dh,al\
sub dh,ah\
sub dx,al\
sub dx,ah\
sub dx,ax\
sub edx,al\
sub edx,ah\
sub edx,ax\
sub edx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


sub dl,bl\
sub dh,bl\
sub dh,bh\
sub dx,bl\
sub dx,bh\
sub dx,bx\
sub edx,bl\
sub edx,bh\
sub edx,bx\
sub edx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


sub dl,dl\
sub dh,dl\
sub dh,dh\
sub dx,dl\
sub dx,dh\
sub dx,dx\
sub edx,dl\
sub edx,dh\
sub edx,dx\
sub edx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



mul al,al\
mul ah,al\
mul ah,ah\
mul ax,al\
mul ax,ah\
mul ax,ax\
mul eax,al\
mul eax,ah\
mul eax,ax\
mul eax,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


mul al,bl\
mul ah,bl\
mul ah,bh\
mul ax,bl\
mul ax,bh\
mul ax,bx\
mul eax,bl\
mul eax,bh\
mul eax,bx\
mul eax,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

mul al,dl\
mul ah,dl\
mul ah,dh\
mul ax,dl\
mul ax,dh\
mul ax,dx\
mul eax,dl\
mul eax,dh\
mul eax,dx\
mul eax,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



mul bl,al\
mul bh,al\
mul bh,ah\
mul bx,al\
mul bx,ah\
mul bx,ax\
mul ebx,al\
mul ebx,ah\
mul ebx,ax\
mul ebx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


mul bl,bl\
mul bh,bl\
mul bh,bh\
mul bx,bl\
mul bx,bh\
mul bx,bx\
mul ebx,bl\
mul ebx,bh\
mul ebx,bx\
mul ebx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


mul bl,dl\
mul bh,dl\
mul bh,dh\
mul bx,dl\
mul bx,dh\
mul bx,dx\
mul ebx,dl\
mul ebx,dh\
mul ebx,dx\
mul ebx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



mul dl,al\
mul dh,al\
mul dh,ah\
mul dx,al\
mul dx,ah\
mul dx,ax\
mul edx,al\
mul edx,ah\
mul edx,ax\
mul edx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


mul dl,bl\
mul dh,bl\
mul dh,bh\
mul dx,bl\
mul dx,bh\
mul dx,bx\
mul edx,bl\
mul edx,bh\
mul edx,bx\
mul edx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


mul dl,dl\
mul dh,dl\
mul dh,dl\
mul dx,dl\
mul dx,dh\
mul dx,dx\
mul edx,dl\
mul edx,dh\
mul edx,dx\
mul edx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



div al,al\
div ah,al\
div ah,ah\
div ax,al\
div ax,ah\
div ax,ax\
div eax,al\
div eax,ah\
div eax,ax\
div eax,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

div al,bl\
div ah,bl\
div ah,bh\
div ax,bl\
div ax,bh\
div ax,bx\
div eax,bl\
div eax,bh\
div eax,dx\
div eax,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



div al,dl\
div ah,dl\
div ah,dh\
div ax,dl\
div ax,dh\
div ax,dx\
div eax,dl\
div eax,dh\
div eax,dx\
div eax,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



div bl,al\
div bh,al\
div bh,ah\
div bx,al\
div bx,ah\
div bx,ax\
div ebx,al\
div ebx,ah\
div ebx,ax\
div ebx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


div bl,bl\
div bh,bl\
div bx,bl\
div bx,bh\
div bx,bx\
div ebx,bl\
div ebx,bh\
div ebx,bx\
div ebx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\


div bl,dl\
div bh,dl\
div bh,dh\
div bx,dl\
div bx,dh\
div bx,dx\
div ebx,dl\
div ebx,dh\
div ebx,dx\
div ebx,edx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\



div dl,al\
div dh,al\
div dh,ah\
div dx,al\
div dx,ah\
div dx,ax\
div edx,al\
div edx,ah\
div edx,ax\
div edx,eax\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

div dl,bl\
div dh,bl\
div dh,bh\
div dx,bl\
div dx,bh\
div dx,bx\
div edx,bl\
div edx,bh\
div edx,bx\
div edx,ebx\

mov eax,9999\
mov ebx,9999\
mov edx,9999\

div dl,dl\
div dh,dl\
div dh,dh\
div dx,al\
div dx,dh\
div dx,dx\
div eax,dl\
div eax,dh\
div eax,dx\
div eax,edx");

return 0;

}

Share this post


Link to post
Share on other sites

I'd guess it's all the \'s :P Couldn't tell you how you get multiple instructions in just the one asm() call though. Really got no idea there, sorry!

 

The while loops condition is wrong for what you want to do (although it won't affect compilation, you just won't get the result you were expecting!) You're assigning i to false there instead of comparing... basically you missed an =

 

You're missing the while loops ending } before return 0; aswell.

 

Took me a while to notice this thread!

 

EDIT: Right, just did some reading. Multiple instructions on one thing should be \n, so like..

 

            asm(
                "mov al,bl\n" 
                "add ax,bx\n"
                "sub ax,10"
            );

 

That kind of thing.

Share this post


Link to post
Share on other sites

... well, tonight's going to be a looooong night.

dang those curly brackets! dang THEM!

480484[/snapback]

 

My piece of advice would be to open and close them before you start writing code for inside them (if you get me?) so if you wanted an if, I immediately do

 

if (something) {

}

 

with the ending }, then put the code inside, not like open it, start writing the code and then hope you remember to close them later..

 

if (something) {
   // do a big poo

 

That way it's kind of hard to forget ending }'s, as you did them before you even started writing the code inside!

 

EDIT: Oh, for your problem... I would have probably tried to do a 'find and replace' finding \ and replacing with \n. That'd save a lot of time. I expect you've already done it by hand now though :rolleyes:

Share this post


Link to post
Share on other sites

:)

 

Search -> Replace

 

Text to find: \

Replace with: \n\

Direction: forward

Scope: Global

Origin: Entire Scope

 

Then hit "Replace All". Should do the trick.

 

EDIT: You'll have to get either rid of all those blank returns you've got all over the place (seperating different types of instructions and such), or replace those with a single \ too though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...