Inline asm problem.

This is a discussion on Inline asm problem. within the C Programming forums, part of the General Programming Boards category; Why won't it work? Code: #include <stdio.h> #include <stdlib.h> #include <dos.h> int myGetch(void) { union REGS regs; regs.x.ah = 16; ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220

    Unhappy Inline asm problem.

    Why won't it work?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <dos.h>
    
    int myGetch(void)
    {
     union REGS regs;
     regs.x.ah = 16;
     int86(22, & regs, & regs);  //ignore the spaces, this is to stop 
     return regs.x.al;               //it doing &reg   grr...
    }
    
    int main(int argc, char *argv[])
    {
     int a = myGetch();
     printf("%c",a);
     return 0;
    }
    errors:
    Code:
    aggregate `union REGS regs' has incomplete type and cannot be initialized
    Last edited by Brian; 03-04-2002 at 01:41 PM.

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    As far as I know, ah and al are not members of union REGS. You should use ax, which is build up of al and ah.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    49
    regs.x.ah = 16;
    For ah and al syntax is :

    regs.h.ah = 16;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  2. Inline ASM ???????
    By datainjector in forum C Programming
    Replies: 5
    Last Post: 09-03-2002, 12:43 PM
  3. inline asm on a sparc
    By Alien_Freak in forum Linux Programming
    Replies: 1
    Last Post: 04-14-2002, 12:43 AM
  4. Inline asm
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-29-2002, 01:42 AM
  5. Inline asm - I love it!
    By wavering in forum C Programming
    Replies: 2
    Last Post: 01-08-2002, 01:19 PM

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