Inline Assembler

This is a discussion on Inline Assembler within the C Programming forums, part of the General Programming Boards category; In the program I am converting from C to VB , there is what I understand is called "Inline Assembly". ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    8

    Inline Assembler

    In the program I am converting from C to VB, there is what I understand is called "Inline Assembly".

    Can someone give me some information on how this is possible or what I could do to accomplish this in another language?

    Could they be made into a DLL?

    Thanks for any leads!


  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Inline assembly is when you paste assembler code in your C source by way of a keyword. This is very compiler specific, so it is not portable to use:
    Code:
    int main ( void )
    {
      __asm {
        /*
        ** Assembler code goes here.
        */
      }
      return 0;
    }
    I recommend searching google for the details of inline assembly for your compiler and system.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    8
    Your example is identical to the what I am seeing in this portion of the C code.

    Now knowing that this code is probably not portable, what options do I have for performing the same operation?

    Would it be best to build a DLL with these two small functions and make a call, or are there libraries out there that are already suffcient for this?

    The Inline ASM is very simple, here it is:

    Code:
    // wait for low
                    do
                    {
    	    asm {
    	    xor	ax,ax
    	    mov 	dx,card_addr
    	    in 	al,dx
    	    mov	port_data,ax
    	}
                    } while ((port_data & 0x01) == 1);
    
    // wait for high
    	do
    	{
    	    asm {
    	    xor	ax,ax
    	    mov 	dx,card_addr
    	    in 	al,dx
    	    mov	port_data,ax
    	    }
    	} while ((port_data & 0x01) == 0);
    How else could I accomplish the same thing??

    Thanks again for your specifics, as they have helped me to understand tremendously.


  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The Inline ASM is very simple, here it is:
    Sure, ASM is simple if you know ASM. Since you're going to VB from C, you naturally don't care about performance. As such, throw together some pseudocode to what the ASM is doing, and turn it into a function.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    8
    Cool... I understand and will try and implement this method.

    Thanks for your help.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. inline assembler as alternative to int86()
    By Bigbio2002 in forum C Programming
    Replies: 3
    Last Post: 11-12-2004, 03:57 PM
  3. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM
  4. Inline Assembler Macros?
    By Aidman in forum C++ Programming
    Replies: 14
    Last Post: 07-15-2003, 05:10 AM
  5. Watcom C++ inline assembler
    By r0x in forum C++ Programming
    Replies: 0
    Last Post: 06-03-2002, 11:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21