home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / C6_BUGS.ZIP / C6_20057.BUG < prev    next >
Text File  |  1990-09-11  |  3KB  |  87 lines

  1. Q62305 _fastcall Register Argument Has Incorrect Value
  2. Microsoft C Compiler (C)
  3. 6.00   | 6.00
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.  
  8. In the case below, the Microsoft C 6.00 compiler will generate
  9. incorrect code for enregistering the arguments of a function declared
  10. with the _fastcall attribute.
  11.  
  12. The following code provides an example of this behavior:
  13.  
  14. Sample Code
  15. -----------
  16.  
  17. #include <stddef.h>
  18.  
  19. void init_windows( void );
  20.  
  21. void _fastcall wxxopen( short   up_r,
  22.                         short   up_c,
  23.                         short   lo_r,
  24.                         short   lo_c,
  25.                         char    *title,
  26.                         short   ctrl,
  27.                         short   dth,
  28.                         short   wth,
  29.                         short   wc,
  30.                         short   fch );
  31.  
  32. void init_windows()
  33. {
  34.     wxxopen( 00, 00, 02, 79, NULL, 10, 0, 0, 0, 32 );
  35.     wxxopen( 04, 01, 11, 78, NULL, 10, 0, 0, 0, 32 );
  36.     wxxopen( 22, 00, 24, 79, NULL, 10, 0, 0, 0, 32 );
  37. }
  38.  
  39. More Information:
  40.  
  41. The incorrectly generated code is for the third call to wxxopen().
  42. Rather than 0 (zero) being placed into the DX register for the second
  43. argument, a copy of the AX register, which contains 22, is moved into
  44. DX. This can be clearly seen in the following code lifted from the
  45. .COD file generated for the above source.
  46.  
  47. Sample Code
  48. -----------
  49.  
  50. ;|***     wxxopen( 22, 00, 24, 79, NULL, 10, 0, 0, 0, 32 );
  51. ; Line 22
  52.         *** 000041      b8 4f 00        mov     ax,79
  53.         *** 000044      50              push    ax
  54.         *** 000045      2b c0           sub     ax,ax
  55.         *** 000047      50              push    ax
  56.         *** 000048      b8 0a 00        mov     ax,10
  57.         *** 00004b      50              push    ax
  58.         *** 00004c      2b c0           sub     ax,ax
  59.         *** 00004e      50              push    ax
  60.         *** 00004f      50              push    ax
  61.         *** 000050      50              push    ax
  62.         *** 000051      56              push    si
  63.         *** 000052      b8 16 00        mov     ax,22
  64.         *** 000055      8b d0           mov     dx,ax
  65.         *** 000057      bb 18 00        mov     bx,24
  66.         *** 00005a      e8 00 00        call    @wxxopen
  67.  
  68. The conditions for the error to occur appear to be very narrowly
  69. defined. The argument being placed into DX must be a constant 0
  70. (zero). The compiler must be in such a state that it considers the AX
  71. register to contain 0 (zero) from a previous operation. This is apparently
  72. the state after the SUB AX, AX instruction above. Regrettably, the AX
  73. register has since been used to hold the first enregistered argument.
  74.  
  75. It is difficult to convince the compiler to reach this state. The
  76. sequence of three calls to wxxopen() with the specified arguments has
  77. been found to reliably produce the error on the third call.
  78.  
  79. Microsoft has confirmed this to be a problem with C 6.00. We are
  80. researching this problem and will post new information here as it
  81. becomes available.
  82.  
  83. Keywords:  buglist6.00
  84.  
  85. COPYRIGHT Microsoft Corporation, 1990.
  86. Updated  90/06/23 05:43
  87.