Thread: Gnu inline assembler question

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    17

    Gnu inline assembler question

    For the GNU assembler...

    is it acceptable to do

    #pragma asm

    #pragma endasm
    or

    #pragma __asm__

    #pragma endasm

  2. #2
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    Quote Originally Posted by Jscott View Post

    For the GNU assembler...
    Assuming you mean GNU as, you might want to befriend the manual https://sourceware.org/binutils/docs/as/

    On the other paw, assuming the above are meant to be assember directives, I haven't seen them on the manual for the few minutes I look neither have I seen the before.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    582
    Or in fact, the GNU compiler manual, for inline assembly

    I guess you're trying to write a sequence of plain assembly instructions (i.e. unquoted, without asm()) in a C/C++ file.

    I don't think you can do this with gcc/g++, at least not as far as I know or could find from a bit of a hunt. Sorry. Looks like you'll have to put up with the clunky syntax, use a separate file, or write a script to turn your blocks into asm()'d blocks. Have fun!

  4. #4
    Registered User
    Join Date
    Jul 2015
    Posts
    17
    I have a long list of board initialization assembly instructions from a project and I was hoping it would be a smooth transition.

    I have seen examples where asm was used like:

    asm("mov #0x05,%d1");

    and

    asm("mov #0x05,%d1"
    "mov #0x69,%eax"
    "jmp off");

    and this as well...

    asm("mov #0x05,%d1
    mov #0x69,%eax
    jmp off");

    I am just trying to see which is actually the best/correct way of doing it.

    I would like to use the last method but i dont think it will be possible.

  5. #5
    Registered User
    Join Date
    Nov 2013
    Posts
    107
    Well have you tried it to see if the compiler throw up an error?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gnu inline assembler question
    By Jscott in forum C++ Programming
    Replies: 5
    Last Post: 07-14-2015, 02:19 PM
  2. inline assembler as alternative to int86()
    By Bigbio2002 in forum C Programming
    Replies: 3
    Last Post: 11-12-2004, 04:57 PM
  3. Inline Assembler Macros?
    By Aidman in forum C++ Programming
    Replies: 14
    Last Post: 07-15-2003, 05:10 AM
  4. Inline Assembler
    By mikef in forum C Programming
    Replies: 4
    Last Post: 08-22-2002, 03:28 PM
  5. Watcom C++ inline assembler
    By r0x in forum C++ Programming
    Replies: 0
    Last Post: 06-03-2002, 11:21 AM

Tags for this Thread