Author Topic: Can RC1 handle inline assembly yet?  (Read 13418 times)

Offline brandon8863

  • Single posting newcomer
  • *
  • Posts: 8
Can RC1 handle inline assembly yet?
« on: July 31, 2005, 06:59:46 pm »
Just looking at the latest release and wondering if CodeBlocks can handle inline assembly code within a C++ project yet.

Thanks,

B--


Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Can RC1 handle inline assembly yet?
« Reply #1 on: July 31, 2005, 07:34:27 pm »
As long as the compiler you're using supports it, I don't see what the problem would be.
Separate assembly files might be a problem because a different executable has to be started to 'compile' it but inline assembly is in the C(++) source file, so the same compiler executable is used as for the rest of that file.
Of course, things like code completion may not work for inline assembly.

EDIT: maybe I misunderstood what you meant by 'handling' inline assembly?

Offline brandon8863

  • Single posting newcomer
  • *
  • Posts: 8
Re: Can RC1 handle inline assembly yet?
« Reply #2 on: July 31, 2005, 07:45:29 pm »
Something like this:

Code: [Select]

#endif
}
else
{
GLfloat *start = (GLfloat *) &((unsigned char *) g.m_colorary)[i*g.m_colorstride];
static float two55 = 255.f;
unsigned int R, G, B, A;

#ifdef _X86_
__asm {
mov ebx, start;
fld [ebx];
fld [ebx + 4];
fld [ebx + 8];
fld [ebx + 12];
fld two55;
fmul st(1), st(0);
fmul st(2), st(0);
fmul st(3), st(0);
fmulp st(4), st(0);...

'Inline assembly code' meaning the use of assembly code inline or flowing with C++?

B--


Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Can RC1 handle inline assembly yet?
« Reply #3 on: July 31, 2005, 08:38:49 pm »
I know what inline assembly is, but I don't understand what you meant when you asked if Code::Blocks can 'handle' it? If you put it in the source file, and the compiler you use supports it, what's the problem?
Maybe I should rephrase my question: what do you think would Code::Blocks have to do to 'handle' inline assembly?
Support assembly code in codecompletion? syntax highlighting? something else? all of the above?

PS: Code completion and syntax highlighting would probably be a bit difficult to handle correctly, as the syntax is rather compiler-dependant and Code::Blocks supports multiple compilers. AFAIK there's not really an ISO standard for inline assembly in C(++).

Offline brandon8863

  • Single posting newcomer
  • *
  • Posts: 8
Re: Can RC1 handle inline assembly yet?
« Reply #4 on: July 31, 2005, 09:10:42 pm »
Ahh, sorry for not being specific enough.

On the features list from the main CodeBlocks page it says this:

Imports MSVC projects and workspaces
   (NOTE: assembly code and inter-project dependencies not supported yet)

I was wondering if the 'Assembly code' part had been supported yet.

Thanks for the quick responses BTW.

B--


Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Can RC1 handle inline assembly yet?
« Reply #5 on: July 31, 2005, 09:24:55 pm »
If I recall correctly, the problem was actually not inline assembly, just separate assembly files. Basically, Code::Blocks doesn't know about them, so it doesn't know what executable (in this case, assembler) to call to compile (or in this case, assemble) and which command-line options to pass to it. Inline assembly should work just fine, though as I said codecompletion and syntax highlighting probably don't support it (haven't tested though).

Offline brandon8863

  • Single posting newcomer
  • *
  • Posts: 8
Re: Can RC1 handle inline assembly yet?
« Reply #6 on: July 31, 2005, 10:31:55 pm »
Thanks Urxae, that is exactly what I wanted to know.

B--


Offline Funto

  • Multiple posting newcomer
  • *
  • Posts: 81
Re: Can RC1 handle inline assembly yet?
« Reply #7 on: July 31, 2005, 10:34:54 pm »
It may be possible to use it with the pre-build steps and post-build steps no?

As for code completion, the only thing which would be useful for inline assembly IMHO would be not to take care of what is between __asm{ (or asm{,  or asm{) and }, because it could put the code completion in a mess, as the syntax is slightly different from C++'s.

On the other hand, who needs code completion with "mov eax, 0" ? (code completion could be useful only with function names...).

Offline brandon8863

  • Single posting newcomer
  • *
  • Posts: 8
Re: Can RC1 handle inline assembly yet?
« Reply #8 on: July 31, 2005, 10:59:06 pm »
Yeah, that's what I thought.. I'm not sure where the code completion topic came from. Who am I to ask such silly questions.?.?

B--


Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Can RC1 handle inline assembly yet?
« Reply #9 on: July 31, 2005, 11:46:32 pm »
On the other hand, who needs code completion with "mov eax, 0" ? (code completion could be useful only with function names...).
I don't know much about inline assembly as I never use it, but can you not use variable names and/or addresses in it? I would think you'd want to have some way of interacting with the rest of the program, so that would be handy...

Besides, how many opcodes exist nowadays? Might be handy to have them autocomplete, provided it also give a hint as to what they do :).
Of course, the fact they don't even have the same names in g++ (AT&T syntax by default, I believe) and VC++ (I'm guessing Intel syntax from the sample provided) might make that somewhat unpractical ;).

I'm not sure where the code completion topic came from.
It came from me not understanding what was meant by 'handling inline assembly yet', as I wasn't aware of any problems with it.

Offline Funto

  • Multiple posting newcomer
  • *
  • Posts: 81
Re: Can RC1 handle inline assembly yet?
« Reply #10 on: August 01, 2005, 01:12:59 am »
Quote
I don't know much about inline assembly as I never use it, but can you not use variable names and/or addresses in it?
That's what I was talking about when I said "code completion could be useful only with function names" ^^

As for opcodes, as you say they vary between Intel's and AT&T's syntaxes (mov versus movw for example), but on the other hand opcodes with more than 5 letters are very rare or even don't existe (at least with Intel's syntax), so there is no need for opcodes-autocompletion IMHO ^^

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Can RC1 handle inline assembly yet?
« Reply #11 on: August 01, 2005, 10:18:14 am »
Quote
I don't know much about inline assembly as I never use it, but can you not use variable names and/or addresses in it?
That's what I was talking about when I said "code completion could be useful only with function names" ^^
I know, I was just nitpicking about functions vs. variables. They're different things, you know ;).

Quote
As for opcodes, as you say they vary between Intel's and AT&T's syntaxes (mov versus movw for example), but on the other hand opcodes with more than 5 letters are very rare or even don't existe (at least with Intel's syntax), so there is no need for opcodes-autocompletion IMHO ^^
True I guess. But as I said, it might be nice if a hint is given as to what they actually do. At least for people who don't usually use assembly (At least not outside my two courses on compilers and embedded systems, neither of which used Intel or AT&T syntax).
Of course AFAIK C::B's code completion doesn't do that either, but it's a bit of a pet project of mine to change that using doxygen comments. Guess that didn't make much sense if you didn't know that (which you couldn't as I haven't mentioned it before).
Which reminds me, I really should work on that some more as I haven't for a few weeks now... :(

Offline Funto

  • Multiple posting newcomer
  • *
  • Posts: 81
Re: Can RC1 handle inline assembly yet?
« Reply #12 on: August 01, 2005, 04:03:35 pm »
Quote
I know, I was just nitpicking about functions vs. variables. They're different things, you know
Of course, but it seems to me that we can either call C functions or use C variable inside inline assembly ^^

As for a little description of what does each opcode, that's a good idea and a feature no other IDE has IMHO ^^

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Can RC1 handle inline assembly yet?
« Reply #13 on: August 06, 2005, 02:41:45 pm »
Quote
I don't know much about inline assembly as I never use it, but can you not use variable names and/or addresses in it?
That's what I was talking about when I said "code completion could be useful only with function names"
You don't use gcc's extended assembly syntax? It is great, should really give it a look.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Can RC1 handle inline assembly yet?
« Reply #14 on: August 08, 2005, 07:50:10 am »
It'll of course vary depending on the compiler (gcc uses gas i guess??? while vc++ toolkit will use masm syntax) and the platform compiled on.  Also assembly languages are constantly changing as new processors come out so is more of a moving target than supporting C compiler library prototypes (really the reason C uses libraries for everything).

FWIW, the following compiles under CB set to VC++ toolkit:
#include <iostream>

int main()
{
    int a;
    __asm
    {
       xor eax,eax
       mov a, 5
    }
    printf("%d\n", a);
   return 0;
}