C files with inline-asm into bmax?
BlitzMax Forums/BlitzMax Programming/C files with inline-asm into bmax?
| ||
Is is possible to import C files that use inline assembly into bmax? Here is an example of what I am trying to do, but gives the error: cpuspeed.c:12: parse error before "_emit" Am I doing something wrong or should I put the C function in a dll instead? (this is not possible in bmax) |
| ||
Stick it in a dll, oh I did it already : http://www.blitzbasic.com/toolbox/toolbox.php?tool=122 |
| ||
I think you need to use "AT&T syntax" assembly in inline code with mingw. |
| ||
Okay I *think* this is the correct AT&T conversion (could be wrong) but still does not compile. cpuspeed.c:12: parse error before ':' token |
| ||
I'm no assembly programmer, but see if this helps at all: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s4 Alternatively, you could possibly create a ".a" library in Fasm directly and import/declare that... not something I can advise any further on though! |
| ||
Stuart somthing like this, all though i could be wrong. but this does compile. im unsure on '_emit' convertion though.#include <windows.h> unsigned __int64 start, stop; unsigned __int64 nCtr, nFreq, nCtrStop; int CpuSpeed(void) { QueryPerformanceFrequency((LARGE_INTEGER *)&nFreq); // __asm__("_emit $0x0F"); // __asm__("_emit $0x31"); __asm__("mov _start,%eax"); __asm__("mov 4+(_start),%edx"); QueryPerformanceCounter((LARGE_INTEGER *)&nCtrStop); nCtrStop += nFreq; do { QueryPerformanceCounter((LARGE_INTEGER *)&nCtr); } while (nCtr < nCtrStop); // __asm__("_emit $0x0F"); // __asm__("_emit $0x31"); __asm__("mov %eax,_stop"); __asm__("mov %edx,4+(_stop)"); return ((stop-start)/1000000); } kev |
| ||
Thanks guys for your help, Ive got it working now. This is what it should have been... |