home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4631 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  3.6 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!matt.ksu.ksu.edu!news
  2. From: holland@matt.ksu.ksu.edu (Rich Holland)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: how long is a clock cycle (was source for DELAY procedure)?
  5. Date: 30 Jul 1992 17:07:39 -0500
  6. Organization: Kansas State University
  7. Lines: 73
  8. Message-ID: <159p7bINNrq6@matt.ksu.ksu.edu>
  9. References: <Bs7Hv8.Bqz@news.cso.uiuc.edu>
  10. NNTP-Posting-Host: matt.ksu.ksu.edu
  11.  
  12. amead@s.psych.uiuc.edu (Alan Mead) writes:
  13.  
  14. >But I see several problems.  FlushKBD will, depending on how I
  15. >implement it, take a different amount of time to execute depending on
  16. >how many keystrokes are in the buffer.
  17.  
  18. No it won't.  Just make the Head and Tail pointers the same.  It will
  19. do the same operation everytime you call FlushKBD, and it will clear
  20. any keystrokes (not overwrite them, just pretend they don't exist).  
  21. Send mail if you need code to do this...
  22.  
  23. >Also, the delay will be longer than period milliseconds by number*<the
  24. >time it takes to execute FlushKBD>.
  25.  
  26. Yup, it will...you could profile FlushKBD though and find out how
  27. long it takes, using the above method.  Since it will take the same
  28. amount of time (# of cycles) to execute every time, this factor can
  29. be figured in...
  30.  
  31. >Which all seems to bear on the value of shorter.  I think that the
  32. >bigger I make it, the less trouble I accrue from the other points.
  33.  
  34. How's that?
  35.  
  36. >And all this stuff would seem to be processor (even machine!)
  37. >specific.  Different machines will execute FlushKBD at different
  38. >speeds.
  39.  
  40. Yup, they will -- a 50mhz 486 will set two pointers equal MUCH faster
  41. than a 4.77mhz XT, won't it?  :-)
  42.  
  43. >Anyone have any suggestions?  Anyone know where in the executable code
  44. >I can find the Delay procedure's initialization data?
  45.  
  46. Sure.  Here's what I did...maybe it'll help, maybe it won't:
  47.  
  48. Just compile this and trace through it:
  49.   Program Test;
  50.   Uses CRT;
  51.   Begin  Inline($90/$90/$90/$90); Delay(500); Inline($90/$90/$90/$90) End.
  52.  
  53. I traced it with TD 1.5 and it looked "normal" to me -- using the clock
  54. tick counter in the BIOS data area (i'm pretty sure).  Here, look at the
  55. disassembly (from DEBUG): 
  56.  
  57. 4AFD:029E 8BDC          MOV    BX,SP                              
  58. 4AFD:02A0 36            SS:                                       
  59. 4AFD:02A1 8B5704        MOV    DX,[BX+04]   ; grab the delay count
  60. 4AFD:02A4 0BD2          OR    DX,DX                              
  61. 4AFD:02A6 7413          JZ    02BB         ; if it's zero, fall out 
  62. 4AFD:02A8 33FF          XOR    DI,DI                              
  63. 4AFD:02AA 8EC7          MOV    ES,DI        ; ES=0 
  64. 4AFD:02AC 26            ES:                                       
  65. 4AFD:02AD 8A05          MOV    AL,[DI]      ; AL=0:[0]   ???  
  66. 4AFD:02AF 8B1E4A00      MOV    BX,[004A]   
  67. 4AFD:02B3 8BCB          MOV    CX,BX        ; CX=0:[4a]  Clock tick count? 
  68. 4AFD:02B5 E80600        CALL    02BE         ; call the "short loop" 
  69. 4AFD:02B8 4A            DEC    DX           ; one less time...
  70. 4AFD:02B9 75F8          JNZ    02B3         ; if not (dx=0) call short loop
  71. 4AFD:02BB CA0200        RETF    0002                               
  72. 4AFD:02BE 26            ES:                 ; SHORT LOOP                      
  73. 4AFD:02BF 3A05          CMP    AL,[DI]      ; wait a bit...
  74. 4AFD:02C1 7502          JNZ    02C5                               
  75. 4AFD:02C3 E2F9          LOOP    02BE                               
  76. 4AFD:02C5 C3            RET                                      
  77.  
  78. See how it works?  Does it help any?
  79.  
  80. -- 
  81. Rich Holland             | INTERNET:  holland@matt.ksu.ksu.edu
  82. 419 Marlatt Hall         | BITNET  :  holland@ksuvm
  83. Manhattan, KS  66506     | UUCP    :  ...rutgers!matt.ksu.ksu.edu!holland
  84. "Jesus saves...but Gretzky gets the rebound!  He shoots!  He scores!!"
  85.