User forums > Using Code::Blocks
As the assembler in kodeblok?
(1/1)
Дмитро:
As the assembler in kodeblok?
I inserted assembler, but no, but no compile end errors occurred.
How can the correct syntax, how to compile this example right?
Please show the code, the correct code is probably the best answer.
--- Code: ---#include <stdio.h>
// definition of constant string
char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "earth";
int main( void )
{
__asm // start ASM code here
{
mov eax, offset world // move the address of world to eax
push eax // Push the address of world to the stack
mov eax, offset hello // eax = &(hello[0])
push eax // push hello to the stack
mov eax, offset format // eax = format
push eax // push format to the stack
call printf // here is the problem printf is not define
// at the time of compilation.
// It will be define in run time.
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
} // end of ASM code
}
--- End code ---
||=== Build: Debug in Asmpr (compiler: GNU GCC Compiler) ===|
C:\ETS-22\main.cpp|13|ошибка: expected «(» before «{» token|
C:\ETS-22\main.cpp|14|ошибка: нет декларации «mov» в этой области видимости|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
:(
yvesdm3000:
You should search for the ASM syntax in GCC.
An example:
--- Code: --- __asm__ ("movl %eax, %ebx\n\t"
"movl $56, %esi\n\t"
"movl %ecx, $label(%edx,%ebx,$4)\n\t"
"movb %ah, (%ebx)");
--- End code ---
Дмитро:
Thank you! Yes, that's understandable.
Дмитро:
And you can still code examples are good to post here? Well all will.
You know, I do not like the syntax is ... Oh I do not like .. The feeling arises distortion present.
Дмитро:
I found a good description, it is only in Russian.
I have this language very well know, almost as a native language.
http://asmcourse.cs.msu.ru/wp-content/uploads/2013/04/gcc-inline-asm.pdf
Navigation
[0] Message Index
Go to full version