Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Serial</strong> DOS<br />
program KeyboardDemo;<br />
uses<br />
Dos, Crt;<br />
const<br />
EscapeKey = #27;<br />
var<br />
OldKeybrdVector: Procedure;<br />
{$F+}<br />
procedure Keyclick; interrupt;<br />
begin<br />
if Port[$60] < $80 then begin<br />
Sound(5000);<br />
Delay(1);<br />
Nosound;<br />
end;<br />
inline($9C) { PUSHF - Push the flags onto the stack }<br />
OldKeybrdVector;<br />
end;<br />
{$F-}<br />
begin<br />
GetIntVec($9,@OldKeybrdVector);<br />
SetIntVec($9,Addr(Keyclick));<br />
repeat<br />
if KeyPressed then begin<br />
OutputLetter := ReadKey;<br />
Write(OutputLetter);<br />
end; {if}<br />
until OutputLetter = EscapeKey;<br />
SetIntVec($9,@OldKeybrdVector);<br />
end.<br />
There are a number of things that this program does, and we need to explore the realm of<br />
16-bit DOS software as well. The 8086 chip designers had to make quite a few compromises<br />
in order to work with the computer technology that was available at the time it was designed.<br />
Computer memory was quite expensive compared to the overall cost of the computer. Most<br />
of the early microcomputers that the IBM-PC was competing against only had 64K or 128K<br />
of main CPU RAM anyway, so huge programs were not considered important. In fact, the<br />
original IBM-PC was designed to operate on only 128K of RAM although it did become<br />
standard with generally up to 640K of main RAM, especially by the time the IBM PC-XT<br />
was released and the market for PC "clones" turned out what is generally considered the<br />
"standard PC" computer today.<br />
The design came up with what is called segmented memory, where the CPU address is<br />
made up of a memory "segment" pointer and a 64K block of memory. That is why some<br />
early software on these computers could only run in 64K of memory, and created nightmares<br />
for compiler authors on the 8086. Pentium computers don't generally have this issue, as the<br />
memory model in "protected mode" doesn't use this segmented design methodology.<br />
4.6.1 Far Procedure Calls<br />
{$F+}<br />
{$F-}<br />
This program has two "compiler switches" that inform the compiler of the need to use what<br />
are called far procedure calls. Normally for small programs and simple subroutines, you are<br />
64