home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01010a < prev    next >
Text File  |  1990-10-26  |  1KB  |  54 lines

  1. FIGURE 1, 
  2.  
  3. ; Line 1
  4. ;|*** 
  5. ;|*** long a = 0x9000;
  6. ;|*** long b = 0x8000;
  7. ;|*** long c;
  8. ;|*** 
  9. ;|*** void thread1(void)
  10. ;|*** {
  11. ; Line 8
  12.      PUBLIC    _thread1
  13. _thread1  PROC NEAR
  14. ;|*** 
  15. ;|***   a = a + b;
  16. ; Line 10
  17.      *** 000000     a1 04 00       mov  ax,WORD PTR _b
  18.      *** 000003     8b 16 06 00         mov  dx,WORD PTR _b+2
  19.      *** 000007     01 06 00 00         add  WORD PTR _a,ax
  20.      *** 00000b     11 16 02 00         adc  WORD PTR _a+2,dx
  21. ;|*** }
  22. ; Line 11
  23.      *** 00000f     c3             ret  
  24.  
  25. _thread1  ENDP
  26. ;|*** 
  27. ;|*** 
  28. ;|*** 
  29. ;|*** void thread2(void)
  30. ;|*** {
  31. ; Line 16
  32.      PUBLIC    _thread2
  33. _thread2  PROC NEAR
  34. ;|*** 
  35. ;|***   c = a;
  36. ; Line 18
  37.      *** 000010     a1 00 00       mov  ax,WORD PTR _a
  38.      *** 000013     8b 16 02 00         mov  dx,WORD PTR _a+2
  39.      *** 000017     a3 00 00       mov  WORD PTR _c,ax
  40.      *** 00001a     89 16 02 00         mov  WORD PTR _c+2,dx
  41. ;|*** }
  42. ; Line 19
  43.      *** 00001e     c3             ret  
  44.      *** 00001f     90             nop  
  45.  
  46. _thread2  ENDP
  47. _TEXT     ENDS
  48. END
  49.  
  50. Caption:  Actual output of the MSC 6.00 compiler.  If thread1
  51. starts, but is interrupted before the instruction at 0000b is
  52. executed, then thread2 runs. But it copies 0x1000 into c, instead
  53. of the true result, 0x11000.  When thread1 resumes, it continues
  54. with, stores the correct result in variable a.