Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ inline Assembler help. (error c2400)
    primarykey
    data
    text
    <p>I'm using Visual Studio 2010. I wrote a program that does a simple Binary Search algorithm. I'm trying to convert it into assemble code. I used the Disassembler to get the assembly code. I'm trying to paste it into _asm. I've tried so many ways and it's just not working.</p> <p>I tried </p> <pre><code>_asm(" . . . ."); _asm( ); _asm{ } &lt;--- -Currently going with this way for c++. seems to work well. </code></pre> <p>seen somewhere online people saying put '\' at the end of each line. That hasn't worked for me.</p> <p>Here's the code. I'll comment where the errors are. well, I have 13 as of now. Some I won't list because they're the same as other errors. Once I fix one or 2 I should be able to fix them all. The orignal c++ code for the function is also in there.It's commented out.</p> <pre><code>bool binarySearch(int searchNum,int myArray[],int size){ _asm{ push ebp mov ebp,esp sub esp,0F0h push ebx push esi push edi lea edi,[ebp-0F0h] mov ecx,3Ch mov eax,0CCCCCCCCh rep stos dword ptr es:[edi] // 217: int first=0,last=size-1,middle; mov dword ptr [first],0 mov eax,dword ptr [size] // ERROR! Error 2 error C2400: inline assembler syntax error in 'second operand'; found ']' sub eax,1 mov dword ptr [last],eax // 218: bool found = false; mov byte ptr [found],0 // 220: while (first &lt;= last) mov eax,dword ptr [first] cmp eax,dword ptr [last] jg binarySearch+80h (0B51970h) //ERROR! Error 4 error C2400: inline assembler syntax error in 'second operand'; found '(' // 222: middle = (first + last)/2; mov eax,dword ptr [first] ; // Error 5 error C2400: inline assembler syntax error in 'opcode'; found '(' add eax,dword ptr [last] ; cdq sub eax,edx sar eax,1 mov dword ptr [middle],eax // 224: if(searchNum &gt; myArray[middle]) mov eax,dword ptr [middle] mov ecx,dword ptr [myArray] mov edx,dword ptr [searchNum] cmp edx,dword ptr [ecx+eax*4] jle binarySearch+61h (0B51951h) // Error 8 error C2400: inline assembler syntax error in 'opcode'; found '(' // 226: first = middle +1; mov eax,dword ptr [middle] add eax,1 mov dword ptr [first],eax jmp binarySearch+7Eh (0B5196Eh) // 228: else if (searchNum &lt; myArray[middle]) mov eax,dword ptr [middle] mov ecx,dword ptr [myArray] mov edx,dword ptr [searchNum] cmp edx,dword ptr [ecx+eax*4] jge binarySearch+7Ah (0B5196Ah) // 230: last = middle -1; mov eax,dword ptr [middle] sub eax,1 mov dword ptr [last],eax // 232: else jmp binarySearch+7Eh (0B5196Eh) // Error 18 error C2400: inline assembler syntax error in 'second operand'; found '(' // 233: return true; mov al,1 // Error 19 error C2400: inline assembler syntax error in 'opcode'; found '(' jmp binarySearch+82h (0B51972h) jmp binarySearch+32h (0B51922h) // Error 22 error C2400: inline assembler syntax error in 'opcode'; found '(' // 236: return false; xor al,al pop edi pop esi pop ebx mov esp,ebp pop ebp ret }; /* int first=0,last=size-1,middle; bool found = false; while (first &lt;= last) { middle = (first + last)/2; if(searchNum &gt; myArray[middle]) { first = middle +1; } else if (searchNum &lt; myArray[middle]) { last = middle -1; } else return true; } return false; */ } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload