How to run Inline Assembly with Compiler Generated Assembly Code

Discussion in 'Assembly Language Programming (ALP) Forum' started by DeVaughnBB, Jun 22, 2022.

  1. DeVaughnBB

    DeVaughnBB New Member

    Joined:
    Jun 21, 2022
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Hi currently I am attempting to use inline assembly language with compiler generated assembly code and while I have known Assembly Language for years this is my 1st time using inline assembly.

    Issue: When I use a section of my compiler generated assembly code in my C++ program which I Inlined I get a syntax error stating that it doesn't recognize my definitions even though they are pulled from my C++ program.

    My Question: How do I fix my Assembly syntax so my Inline Assembly Code will read my Assembly data?

    My Assembly Code and list of errors are below

    Software I am using: Microsoft Visual Studio 2008 C++
    Platform: Windows 10

    If you need additional specs due to it being Assembly Language let me know

    Code:
    #include "DarkGDK.h"
    
    #include "Profiler.h"
    
    #include <windows.h>
    
        
    using namespace std;
        
    
    
    void DarkGDK( void )
    {
        //-----This is the end of the include process------------------//
        //------This is the start of the program-----------------------//
    
        const int RADIUS = 50;
    
        // Variables for the circle's XY coordinates.
        // We initialize these with the cordinates of
        // the center of the screen.
        int x = dbScreenWidth() / 2;
        int y = dbScreenHeight() / 2;
    
        
    
    
        
        dbSyncOn();      // Disable auto screen refresh
        dbSyncRate(60);  // Set the maximum screen refresh rate
    
        // The game loop
        
            while ( LoopGDK())
             {
                 //-----This is just the profiler skip------------------//
                 PROFILER_FRAME("DarkGDK( void )");
                 PROFILE
                 PROFILER_CATEGORY( "dbUpKey", Profiler::Color::Aqua )
                 PROFILER_CATEGORY( "dbDownKey", Profiler::Color::CadetBlue )
                 PROFILER_CATEGORY( "dbLeftKey", Profiler::Color::DarkGray )
                 PROFILER_CATEGORY( "dbRightKey", Profiler::Color::Magenta )
                 //-----This is just the profiler end skip------------------//
        
    
            // Clear the screen.
    
    
            dbCLS();
    
            // Draw the circle at its current location.
            //dbCircle(x, y, RADIUS);
    
    
    __asm
    {
    
    
    
    
    
    
     // ; //---------------------------------------------This is the part of the Optimization Attempt-----------------------------------------------------//
    
    //; 50   :
    //; 51   :         // If any arrow key is being pressed, then
    //; 52   :         // move the circle acccordingly.
    //; 53   :
    //; 54   :         //---What I am attempting to optimize
    //; 55   :
    //; 56   :     if ( dbUpKey() )
    
        call    ?dbUpKey@@YAHXZ                //; dbUpKey
        test    eax, eax
        je    SHORT $LN4@DarkGDK
    
    //; 57   :     {
    //; 58   :         y--;
    
        mov    eax, DWORD PTR _y$[ebp]
        sub    eax, 1
        mov    DWORD PTR _y$[ebp], eax
    $LN4@DarkGDK:
    
    //; 59   :     }
    //; 60   :
    //; 61   :     if ( dbDownKey() )
    
        call    ?dbDownKey@@YAHXZ            //; dbDownKey
        test    eax, eax
        je    SHORT $LN3@DarkGDK
    
    //; 62   :     {
    //; 63   :         y++;
    
        mov    eax, DWORD PTR _y$[ebp]
        add    eax, 1
        mov    DWORD PTR _y$[ebp], eax
    $LN3@DarkGDK:
    
    //; 64   :     }
    //; 65   :
    //; 66   :     if ( dbLeftKey() )
    
        call    ?dbLeftKey@@YAHXZ            //; dbLeftKey
        test    eax, eax
        je    SHORT $LN2@DarkGDK
    
    //; 67   :     {
    //; 68   :         x--;
    
        mov    eax, DWORD PTR _x$[ebp]
        sub    eax, 1
        mov    DWORD PTR _x$[ebp], eax
    $LN2@DarkGDK:
    
    //; 69   :     }
    //; 70   :
    //; 71   :     if (dbRightKey() )
    
        call    ?dbRightKey@@YAHXZ            //; dbRightKey
        test    eax, eax
        je    SHORT $LN1@DarkGDK
    
    //; 72   :     {
    //; 73   :         x++;
    
        mov    eax, DWORD PTR _x$[ebp]
        add    eax, 1
        mov    DWORD PTR _x$[ebp], eax
    $LN1@DarkGDK:
    
    //; 74   :     }
    //; 75   :     //---What I am attempting to optimize
    //; 76   :
    
    //; //---------------------------------------------This is the part of the Optimization Attempt End-----------------------------------------------------//
    
    
    }
    
    
    
    
    
    
    
            // If any arrow key is being pressed, then
            // move the circle acccordingly.
    
            //---What I am attempting to optimize
    
        /*if ( dbUpKey() )
        {
            y--;
        }
    
        if ( dbDownKey() )
        {
            y++;
        }
    
        if ( dbLeftKey() )
        {
            x--;
        }
    
        if (dbRightKey() )
        {
            x++;
        }
        //---What I am attempting to optimize
    */
    
        // Update the screen.
        dbSync();
    
        //WinExec("C:\Users\DeVaughn\Documents\MasmAssemblyLanguagefileexamples\run.bat",SW_SHOWNORMAL);
        
             }
    
            //---Where the program has ended----//
      
    }

    Below are my list of errors

    Code:
    Error    3    error C2018: unknown character '0x40'        line 73
    Error    4    error C2018: unknown character '0x40'        line 73
    Error    7    error C2018: unknown character '0x40'        line 75
    Error    9    error C2018: unknown character '0x40'        line 83
    Error    13    error C2018: unknown character '0x40'        line 89
    Error    14    error C2018: unknown character '0x40'        line 89
    Error    17    error C2018: unknown character '0x40'        line 91
    Error    19    error C2018: unknown character '0x40'        line 99
    Error    23    error C2018: unknown character '0x40'        line 105
    Error    24    error C2018: unknown character '0x40'        line 105
    Error    27    error C2018: unknown character '0x40'        line 107
    Error    29    error C2018: unknown character '0x40'        line 115
    Error    33    error C2018: unknown character '0x40'        line 121
    Error    34    error C2018: unknown character '0x40'        line 121
    Error    37    error C2018: unknown character '0x40'        line 123
    Error    39    error C2018: unknown character '0x40'        line 131
    Error    2    error C2400: inline assembler syntax error in 'first operand'; found 'bad token'        line 73
    Error    12    error C2400: inline assembler syntax error in 'first operand'; found 'bad token'        line 89
    Error    22    error C2400: inline assembler syntax error in 'first operand'; found 'bad token'        line 105
    Error    32    error C2400: inline assembler syntax error in 'first operand'; found 'bad token'        line 121
    Error    8    error C2400: inline assembler syntax error in 'first operand'; found 'newline'        line 75
    Error    18    error C2400: inline assembler syntax error in 'first operand'; found 'newline'        line 91
    Error    28    error C2400: inline assembler syntax error in 'first operand'; found 'newline'        line 107
    Error    38    error C2400: inline assembler syntax error in 'first operand'; found 'newline'        line 123
    Error    5    error C2400: inline assembler syntax error in 'opcode'; found 'bad token'        line 74
    Error    15    error C2400: inline assembler syntax error in 'opcode'; found 'bad token'        line 90
    Error    25    error C2400: inline assembler syntax error in 'opcode'; found 'bad token'        line 106
    Error    35    error C2400: inline assembler syntax error in 'opcode'; found 'bad token'        line 122
    Error    10    error C2400: inline assembler syntax error in 'opcode'; found 'DarkGDK'        line 83
    Error    20    error C2400: inline assembler syntax error in 'opcode'; found 'DarkGDK'        line 99
    Error    30    error C2400: inline assembler syntax error in 'opcode'; found 'DarkGDK'        line 115
    Error    40    error C2400: inline assembler syntax error in 'opcode'; found 'DarkGDK'        line 131
    Error    1    error C2414: illegal number of operands        line 73
    Error    11    error C2414: illegal number of operands        line 89
    Error    21    error C2414: illegal number of operands        line 105
    Error    31    error C2414: illegal number of operands        line 121
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice