Author Topic: As the assembler in kodeblok?  (Read 6795 times)

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
As the assembler in kodeblok?
« on: June 15, 2016, 02:26:20 pm »
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 = &amp;(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
}


||=== 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)) ===|
 :(
« Last Edit: June 15, 2016, 02:33:36 pm by Дмитро »

Offline yvesdm3000

  • Almost regular
  • **
  • Posts: 225
Re: As the assembler in kodeblok?
« Reply #1 on: June 15, 2016, 03:42:35 pm »
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)");
Clang based code completion for Code::Blocks:   http://github.com/yvesdm3000/ClangLib

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: As the assembler in kodeblok?
« Reply #2 on: June 15, 2016, 03:51:43 pm »
Thank you! Yes, that's understandable.

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: As the assembler in kodeblok?
« Reply #3 on: June 15, 2016, 06:04:33 pm »

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.

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: As the assembler in kodeblok?
« Reply #4 on: June 15, 2016, 06:59:10 pm »
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