home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / msdos / programm / 11758 < prev    next >
Encoding:
Text File  |  1993-01-03  |  2.6 KB  |  90 lines

  1. Xref: sparky comp.os.msdos.programmer:11758 alt.msdos.programmer:3073 rec.games.programmer:5244
  2. Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,rec.games.programmer
  3. Path: sparky!uunet!spool.mu.edu!umn.edu!news.cs.indiana.edu!lynx!hydra.unm.edu!cslewis
  4. From: cslewis@hydra.unm.edu (Scott Lewis)
  5. Subject: Need help with Phar Lap DOS Extender and assembly
  6. Message-ID: <g8trrpd@lynx.unm.edu>
  7. Date: Sun, 03 Jan 93 08:29:53 GMT
  8. Organization: University of New Mexico, Albuquerque
  9. Lines: 79
  10.  
  11.  
  12. I am trying to program a graphics application with BC++ 3.1 and
  13. Phar Lap 286 Dos Extender Lite.  I need to write directly to the
  14. video memory, but can't seem to do this successfully.  Perhaps
  15. someone could help me solve this problem.
  16.  
  17. Before using the Dos extender I was writing directly to segment
  18. A000h in VGA mode 13h.  Now I'm calling DosMapRealSeg () to 
  19. create a selector to A000h, but when I use that selector in an
  20. assembly routine to write to the screen, I get a general protection
  21. fault.
  22.  
  23. The function DosMapRealSeg () seems to be returning a legitimate
  24. selector (22CFh), but I get a fault at this line in the ASM code:
  25.  
  26.   mov  es:[di], al  ;ES contains the selector to A000h, di the offset
  27.  
  28. Can anyone offer any suggestions to solve this problem? Attached
  29. below is the C code with inline assembly and the error message.
  30.  
  31. Thanks in advance,
  32.  
  33. Scott Lewis
  34. cslewis@hydra.unm.edu
  35. ----
  36.  
  37. #include <dos.h>
  38. #include <conio.h>
  39. #include "vga.h"
  40.  
  41. #ifdef DOSX286
  42. #include <phapi.h>
  43. #endif
  44.  
  45. int drawPixel (int x, int y, int color);
  46.  
  47. main ()
  48. {
  49. int i;
  50. extern unsigned short vga_seg;         // vga_seg is initialized with
  51.                                        // DosMapRealSeg (), in another
  52. vgaInit (0x0013);                      // module, which contains
  53.                                        // vgaInit () and vgaClose ().
  54. for (i=0; i<320; i++)
  55.     drawPixel (i, 100, 4);
  56. getch ();
  57.  
  58. vgaClose ();
  59. return 0;
  60. }
  61.  
  62. drawPixel (int x, int y, int color)
  63. {
  64. extern unsigned short vga_seg;
  65.  
  66. asm    mov ax, vga_seg
  67. asm    mov es, ax
  68. asm    mov ax, 320
  69. asm    mul y                           // The fault is occuring in this
  70. asm    add ax, y                       // routine, at the last line,
  71. asm    mov di, ax                      // I believe.
  72. asm    mov ax, color
  73. asm    mov es:[di], al
  74.  
  75. return 0;
  76. }
  77.  
  78. When run, the code gives this error message:
  79.  
  80. Fatal error 286.3330: General protection fault detected.
  81. PID=0001  TID=0001  SID=0001  ERRORCODE=0000
  82. AX=0004  BX=0017  CX=0013  DX=0000  SI=0000  DI=7D64  BP=0FE2
  83. CS:IP=024F:004C   DS=0267  ES=22CF  SS:SP=026F:0FE0   FLAGS=2202
  84.  
  85. -- 
  86. ---------------------
  87. Scott Lewis
  88. cslewis@vesta.unm.edu
  89. ---------------------
  90.