home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / PAGWRITE.ZIP / SPEEDCHK.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1985-10-07  |  5.6 KB  |  143 lines

  1. {       This progam is meant to demonstrate the increase in speed achieved
  2. by using the WriteChar procedure which writes directly to screen memory
  3. instead of going through the BIOS interrupt INT 10. In Turbo Pascal 2.0
  4. I noticed a speed increase of 5 to 1 when there are no scrolls involved
  5. and 3.5 to 1 when the screen has to be scrolled on my AT&T 6300 machine.
  6. Turbo Pascal 3.0 apparently uses direct screen memory access already, so
  7. speed increases may not be that drastic.. and these numbers might be
  8. different on the IBM, since the AT&T with its 16 bit bus can write to memory
  9. faster when writing 16 bit words (The screen output routine does that since
  10. it outputs the character and its attribute together as a word) }
  11.  
  12.  
  13. const
  14. Attribute:byte =15;          {Attribute of characters to be written}
  15. Out_Page: byte =0;          {Page to which Write and Writeln procedures
  16.                              would output characters to}
  17.  
  18.  
  19. Procedure  Textcolor(a:byte);
  20. {****************************************************************************
  21. Replaces Standard Turbo Procedure TextColor
  22. *****************************************************************************}
  23. begin
  24. Attribute:=(Attribute and $70)+(a and 15)+((a and 16) shl 3)
  25. end;
  26.  
  27. Procedure Textbackground(a:byte);
  28. {****************************************************************************
  29. Replaces Standard Turbo Procedure TextBackground.
  30. *****************************************************************************}
  31. begin
  32. Attribute:=(Attribute and $8F) + ((a and 7) shl 4)
  33. end;
  34.  
  35.  
  36. Procedure Writechar(InChar:Char);
  37. {**************************************************************************
  38.     This procedure outputs the character "Inchar" to the page defined by
  39. Out_Page. Direct output to screen memory is utilized to obtain high speed
  40. display.The attribute of characters written is the one defined as "Attribute".
  41. It may be noted that procedures standard Turbo Procedures TextColor and
  42. Textbackground also have been redefined, so that these statements can change
  43. the value of the "Attribute" byte.
  44. *****************************************************************************}
  45. begin
  46. Inline ($FB/$33/$DB/$1E/$BA/$40/$00/$8E/$DA/$2E/$8A/$1E/Out_page/$80/$E3/
  47.         $07/$D1/$E3/$8B/$57/$50/$B9/$00/$B8/$8E/$C1/$52/$B8/$00/$08/$F7/
  48.         $E3/$5A/$8B/$C8/$8B/$86/Inchar/$2E/$8A/$26/Attribute/$8B/$F0/$3C/
  49.         $07/$75/$08/$B4/$0E/$CD/$10/$FE/$C2/$EB/$44/$3C/$0D/$74/$3C/$3C/
  50.         $0A/$74/$2F/$3C/$08/$74/$38/$8B/$F9/$B8/$50/$00/$F6/$E6/$52/$32/
  51.         $F6/$03/$C2/$D1/$E0/$03/$F8/$BA/$DA/$03/$EC/$D0/$D8/$72/$FB/$FA/
  52.         $EC/$D0/$D8/$73/$FB/$8B/$C6/$AB/$FB/$5A/$42/$80/$FA/$50/$72/$59/
  53.         $32/$D2/$80/$FE/$18/$73/$10/$FE/$C6/$EB/$4E/$32/$D2/$EB/$4A/$0A/
  54.         $D2/$74/$75/$FE/$CA/$EB/$42/$1E/$52/$BA/$00/$B8/$8E/$C2/$8E/$DA/
  55.         $8B/$F9/$8B/$C6/$8B/$F1/$81/$C6/$A0/$00/$B9/$B0/$07/$B0/$20/$BA/
  56.         $DA/$03/$EC/$A8/$08/$74/$FB/$BA/$D8/$03/$B0/$01/$EE/$FA/$FC/$F3/
  57.         $A5/$B9/$50/$00/$B0/$20/$F3/$AB/$BA/$DA/$03/$EC/$A8/$08/$74/$FB/
  58.         $BA/$D8/$03/$B0/$09/$EE/$FB/$5A/$1F/$89/$57/$50/$D1/$EB/$3A/$1E/
  59.         $62/$00/$75/$24/$B0/$A0/$F6/$E6/$30/$F6/$D1/$E2/$01/$D0/$03/$06/
  60.         $4E/$00/$D1/$E8/$BA/$D4/$03/$89/$C1/$B0/$0E/$EE/$42/$88/$E8/$EE/
  61.         $B0/$0F/$4A/$EE/$42/$88/$C8/$EE/$1F)
  62. end;
  63.  
  64. Procedure Display_Page(a:byte);
  65. {****************************************************************************
  66.   This procedure is used to switch screen display pages.4 pages (0 to 3) are
  67. available with the color graphics adapter in the 80 column display mode.
  68. *****************************************************************************}
  69. begin
  70. Inline($B4/$05/$8A/$86/a/$24/$03/$CD/$10)
  71. end;
  72.  
  73. var
  74. i,j:byte;
  75. C:char;
  76. p:integer absolute $0040:$006C;
  77. p1,p2:integer;
  78. t1,t2,t3,t4,t:real;
  79.  
  80. {Main program
  81. Compares time difference between standard and Direct screenwrite}
  82. begin
  83. ClrScr;
  84. p1:=p;
  85.      For j:= 1 to 20 do
  86.        begin
  87.        Writeln('ABCD',j:75)
  88.        end;
  89. p2:=p;
  90. t:=(p2-p1)/18.2;
  91. t1:=t;
  92. Writeln('Turbo Standard output....20 lines of 79 characters, no scroll');
  93. Writeln('Start Count:',p1:7,'  End Count:',p2:7,'  Time taken:',t:9:6,' seconds');
  94. Writeln('Press any key to continue...');
  95. Read(kbd,C);
  96. Writeln('');
  97. Writeln('');
  98. p1:=p;
  99.      For j:= 1 to 20 do
  100.        begin
  101.        Writeln('ABCD',j:75)
  102.        end;
  103. p2:=p;
  104. t:=(p2-p1)/18.2;
  105. t2:=t;
  106. Writeln('Turbo Standard output....20 lines of 79 characters, 20 scrolls');
  107. Writeln('Start Count:',p1:7,'  End Count:',p2:7,'  Time taken:',t:9:6,' seconds');
  108. Writeln('Press any key to continue...');
  109. Read(Kbd,C);
  110. ConOutPtr:=Ofs(WriteChar); {Use the procedure Writechar for outputs to screen}
  111. ClrScr;
  112. p1:=p;
  113.      For j:= 1 to 20 do
  114.        begin
  115.        Writeln('ABCD',j:75)
  116.        end;
  117. p2:=p;
  118. t:=(p2-p1)/18.2;
  119. t3:=t;
  120. Writeln('Direct screen output....20 lines of 79 characters, No scrolls');
  121. Writeln('Start Count:',p1:7,'  End Count:',p2:7,'  Time taken:',t:9:6,' seconds');
  122. Writeln('Press any key to continue...');
  123. Read(kbd,C);
  124. Writeln('');
  125. Writeln('');
  126. p1:=p;
  127.      For j:= 1 to 20 do
  128.        begin
  129.        Writeln('ABCD',j:75)
  130.        end;
  131. p2:=p;
  132. t:=(p2-p1)/18.2;
  133. t4:=t;
  134. Writeln('Direct screen output....20 lines of 79 characters, 20 scrolls');
  135. Writeln('Start Count:',p1:7,'  End Count:',p2:7,'  Time taken:',t:9:6,' seconds');
  136. Writeln('Press any key to continue...');
  137. Read(Kbd,C);
  138. ClrScr;
  139. Writeln('':30,'Turbo Standard':15,'Direct screen':15,'Comparison':15);
  140. Writeln('20 lines,no scrolls':20,'':10,t1:15:6,t3:15:6,t1/t3:12:3,':1');
  141. Writeln('20 lines,20 scrolls':20,'':10,t2:15:6,t4:15:6,t2/t4:12:3,':1');
  142. end.
  143.