home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / msdos / programm / 12321 < prev    next >
Encoding:
Text File  |  1993-01-21  |  3.9 KB  |  109 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!bogus.sura.net!opusc!usceast!douglas
  3. From: douglas@cs.scarolina.edu (G. David Douglas Jr.)
  4. Subject: Re: INT in TC2.0
  5. Message-ID: <douglas.727660894@willow.cs.scarolina.edu>
  6. Sender: usenet@usceast.cs.scarolina.edu (USENET News System)
  7. Organization: USC  Department of Computer Science
  8. References: <1993Jan20.202931.4370@dcc.uchile.cl>
  9. Date: 22 Jan 93 00:01:34 GMT
  10. Lines: 97
  11.  
  12. ereimber@cipres.cec.uchile.cl (Reimberg Navarro Erich Eduardo) writes:
  13.  
  14. >Hi.
  15.  
  16. >>     The main difference is that intr() is using only 1 struct which
  17. >>     contains the registers both before and after the execution of
  18. >>     the interrupt. intr() is unique to Borland while int86 is quite
  19. >>     common among C compiler for DOS.
  20.  
  21. >   Thank you for your reply. BUt there are some stuff I still can't
  22. >get right. int86 uses a union for both the passed registers and the
  23. >returned ones. I have this as:
  24.  
  25. >  int86 (int intno, union REGS *inregs, union REGS *outregs)
  26.  
  27. >  while union REGS is as:
  28.  
  29. >   union REGS {
  30. >      struct WORDREGS x;   /* Word-sized registers */
  31. >      struct BYTEREGS h;   /* Byte-sized registers */
  32. >   }
  33. >   struct BYTREGS contains registers al, ah, bl, bh, cl, ch, dl, dh;
  34. >   and struct WORDREGS, ax, bx, cx, dx, si, di, cflag, flags;
  35.  
  36. >  There are some INT calls, that return pointers in the form DS:BX. And
  37. >I don't have any DS register in either WORDREGS or BYTEREGS.
  38. >There's another struct called REGPACK that does have the DS register
  39. >in the form      
  40. >   unsigned r_ds;      but it has no ah, al, bh, ....
  41.  
  42. ** You could get ah from (r_ax >> 16), and al from
  43. ** (r_ax & 0xFF), where r_ax IS an element of the REGPACK structure, since
  44. ** the AX register's high-half is known as AH and its low-half is known
  45. ** as AL.  Storing a value, say  x,  in AH and another value, say  y,
  46. ** in AL, could be done (assuming x and y are both in the range
  47. ** 0 through 255) with  ((x << 16) | y)
  48.  
  49. >The fact is that I'm trying to execute INT 0x21 with AL=0x1c. INT 0x21
  50. >returns a pointer in the form DS:BX. Here I use both AL, and DS registers,
  51. >but I can't figure out how can I handle both registers with only
  52. >one call. (?)
  53.  
  54. >                             -ern
  55.  
  56. >--
  57. >PS: I could not reply via e-mail.
  58.  
  59. Well, I'm currently (still?) using TC 1.5, doing something similar to
  60. what you want to do:  use INT 0x21, but with AH=0x52.
  61. The following code fragment should help clear up any misunderstandings
  62. on using the  intr  command  .  (I'm loading a value into the AH
  63. pseudo-register by specifying the (bigger) value for the entire AX
  64. register, with 0x00 as the value stored in the AL pseudo-register).
  65.  
  66.  
  67.  
  68.         struct REGPACK    cpu_registers;
  69.         unsigned int      *word_pointer;
  70.  
  71.    ...
  72.  
  73.         /*
  74.          *  Prefix string setup is now done.
  75.          *
  76.          *  Issue a PC-DOS service number 52h call to retrieve the
  77.          *  segment and offset of the last location "officially"
  78.          *  occupied by DOS.  Segment will be contained in the ES
  79.          *  pseudo-register, offset in the BX pseudo-register.  Subtract
  80.          *  2 from BX to get offset of the 2 bytes containing segment number
  81.          *  of the first Memory Control Block (MCB).
  82.          */
  83.  
  84.         cpu_registers.r_ax = 0x5200;  /* AH register <- 0x52,          */
  85.                                       /* AL register <- 0x00           */
  86.  
  87.         intr(0x21, &cpu_registers);
  88.  
  89.         cpu_registers.r_bx -= 2;
  90.  
  91.         /*
  92.          *  Load segment and offset into pointer variable -- r_es and
  93.          *  r_bx pseudo_registers (as well as actual registers ES and
  94.          *  BX) are 16 bits in width, so shift ES component left 16
  95.          *  bits before including the offset contained in BX.
  96.          */
  97.  
  98.         word_pointer = (unsigned int *)(((long)cpu_registers.r_es << 16) |
  99.                                          (long)cpu_registers.r_bx);
  100.  
  101.  
  102.  
  103. Hope this helps!
  104.  
  105.  
  106. David Douglas
  107. douglas@usceast.cs.scarolina.edu
  108.  
  109.