title: How to resolve "Error 200: Division by zero"?
body: <p>I've FreeDos OS installed on VirtualBox on a windows xp, dual core, host machine. I installed FreeDos because I wanted to run a Pascal code using Turbo Pascal. When I run the code, it throws error 'Error 200: Division by zero.'. How can I solve this?</p>
  
  <p>-Turbo Pascal 7.0, Free DOS 1.1, Virtual Box 4.3.6, Windows XP Service Pack 3 Host machine
  -This error is unfortunately caused by fast Pentium CPUs and I found a patch on the internet that will resolve the error. (<a href="http://www.filewatcher.com/m/bp7patch.zip.62550-0.html" rel="nofollow">www.filewatcher.com/m/bp7patch.zip.62550-0.html</a>) Now the other problem is, when i was tracing the code, it hangs at '<code>RxWait</code> procedure when trying to execute <code>while not odd(port[RXTX + 5]</code>) do;'</p>
  
  <pre><code>uses crt;
  
  const
  { COM1: RS232 port address }
  RXTX = $3F8; { $2F8 if COM2: is used }
  ACK = 6;
  NAK = 21;
  ESC = 27;
  
  var
  dummy,
  checkSum : integer;
  key : char;
  protocol : integer;
  
  procedure InitComm;
  { Set baudrate to 9600, 8 bits, no parity, 1 stop bit }
  var i : integer;
  begin
  i := 1843200 div 9600 div 16;
  port[RXTX + 3] := $80;
  port[RXTX + 1] := hi(i);
  port[RXTX]:= lo(i);
  port[RXTX + 3] := 3;
  port[RXTX + 4] := $A;
  while odd(port[RXTX + 5]) do
  begin
  dummy := port[RXTX];
  delay(10);
  end;
  end; { InitComm }
  
  procedure Tx(data : integer);
  { Transmit a character on serial channel }
  begin
  while port[RXTX + 5] and $20 = 0 do;
  port[RXTX] := data and $FF;
  end; { Tx }
  
  function RxWait : integer;
  { Waits for a character from serial channel }
  begin
  while not odd(port[RXTX + 5]) do;
  RxWait := port[RXTX];
  end; { RxWait }
  
  procedure Tx2(data : integer);
  { Transmit a char on serial channel + Calculate check sum }
  begin
  Tx(data);
  checkSum := (checkSum + data) and $FF;
  end; { Tx2 }
  
  procedure TxCommand(c1, c2 : char;
  sendCheckSum : boolean);
  { Transmit command (no data) on serial channel }
  begin
  Tx(ESC);
  checkSum := 0;
  Tx2(ord(c1));
  Tx2(ord(c2));
  if sendCheckSum then
  begin
  Tx2(checkSum);
  dummy := RxWait;
  end;
  end; { TxCommand }
  
  function ReadNumber(n : integer) : real;
  { Read n bytes from serial channel }
  var
  number: real;
  i : integer;
  begin
  number := 0;
  checkSum := 0;
  for i := 1 to n do
  number := number * 256 + RxWait;
  dummy := RxWait;
  ReadNumber := number;
  end; { ReadNumber }
  
  procedure Revisions;
  var
  tmp : integer;
  sw,
  prot : real;
  begin
  TxCommand('P', 'R', FALSE);
  checkSum := 0;
  tmp := RxWait;
  sw := tmp + RxWait / 100.0;
  protocol := RxWait;
  prot := protocol + RxWait / 100.0;
  dummy := RxWait;
  tmp := RxWait;
  writeln('Software revision: ', sw:4:2);
  writeln('Protocol revision: ', prot:4:2);
  end; { Revisions }
  
  procedure ReadCountReg;
  begin
  TxCommand('R', 'C', FALSE);
  writeln(ReadNumber(4):11:0, ' coins counted.');
  dummy := RxWait;
  end; { ReadCountReg }
  
  procedure ReadAccReg;
  begin
  TxCommand('R', 'A', FALSE);
  writeln(ReadNumber(4):11:0, ' coins in accumulator.');
  dummy := RxWait;
  end; { ReadAccReg }
  
  procedure Setbatch(limit : longint);
  begin
  TxCommand('W', 'L', FALSE);
  case protocol of
  1 : begin
  Tx2(limit div 256);
  Tx2(limit mod 256);
  end;
  2 : begin
  Tx2( limit div 16777216);
  Tx2((limit div 65536) mod 256);
  Tx2((limit div 256) mod 256);
  Tx2( limit mod 256);
  end;
  end; { case protocol }
  Tx2(checkSum);
  dummy := RxWait;
  end; { Setbatch }
  </code></pre>