home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8973 < prev    next >
Encoding:
Text File  |  1992-09-01  |  2.2 KB  |  71 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!uunet.ca!geac!zooid!ross
  3. From: Ross Ridge <ross@zooid.guild.org>
  4. Subject: Re: Results of the smallest TSR contest
  5. Organization: ZOOiD BBS
  6. Date: Tue, 1 Sep 1992 21:24:08 GMT
  7. Message-ID: <1992Sep1.212408.7974@zooid.guild.org>
  8. References: <BtvM6J.70o@ireq.hydro.qc.ca>
  9. Lines: 60
  10.  
  11. beaurega@ireq.hydro.qc.ca (Denis Beauregard) writes:
  12. >In the category : HLL with Assembly
  13. >  Ross Ridge
  14. >  64 bytes for a TSR counter
  15. >
  16. >Note : I have no Borland compiler on hand.  But, statements like
  17. >#define get_strategy() (_AX=0x5800, INT21(), _AX)
  18. >looks like inline functions.  What is doing _AX=0x5800 ?  Compiling
  19. >this into "mov ax,$5800" ?  If true, this is inline!
  20.  
  21. No it's not.  _AX=0x5800 isn't assembler, it doesn't even look
  22. like assembler.  But it was only used for convience, these functions
  23. could easily have been written (more portability) like this:
  24.  
  25.     int
  26.     get_strategy(void) {
  27.         union REGS regs;
  28.  
  29.         regs.x.ax = 0x5800;
  30.         intdos(®s, ®s);
  31.         return regs.x.ax;
  32.     }
  33.  
  34. The only use of register pseudovariables that's required is at the
  35. start of the isr funtion:
  36.  
  37.     _DS = _CS;
  38.  
  39. Again this isn't assembler, you can't even do that in assembler, as
  40. "mov ds,cs" is illegal.  The compiler is has to take the statement,
  41. expressed in C, of "assign the code segment register to the data 
  42. segment register" and translate it into assembler.  It even has
  43. a view choices of how to do this:
  44.  
  45.     push cs
  46.     pop ds
  47. or...
  48.     mov ax,cs
  49.     mov ds,ax
  50.  
  51. In the latter case it could use bx, cx, or dx instead of ax.  Maybe
  52. si and di too, I dunno, I don't care.  I'm no 8086 assembler wiz,
  53. in fact when I first used a statement like "_ES = _DS;" I didn't
  54. even realize that it couldn't be translated into assembly as
  55. one statement.
  56.  
  57. >My own entry : doing the key swapper in HLL + Inline.
  58. >Let's presume I use the same loader as Ross' program.
  59. >The result would give 48 bytes.  Compare with 160 bytes without assembly.
  60.  
  61. My loader can't create an TSR less than 64 bytes including the MCB because
  62. parts of the new PSP are modified by MS-DOS while setting it up.
  63.  
  64.                             Ross Ridge
  65.  
  66. -- 
  67. Ross Ridge - The Great HTMU                         l/     //
  68.                                     [OO][oo]
  69. ross@zooid.guild.org                            /()\/()/
  70. uunet.ca!zooid!ross                             db     //
  71.