如何解决“错误200:除零”?

时间:2014-02-08 14:41:13

标签: turbo-pascal

我在Windows xp,双核,主机上的VirtualBox上安装了FreeDos OS。我安装了FreeDos,因为我想使用Turbo Pascal运行Pascal代码。当我运行代码时,它会抛出错误'错误200:除以零。'。我该如何解决这个问题?

-Turbo Pascal 7.0,免费DOS 1.1,Virtual Box 4.3.6,Windows XP Service Pack 3主机 - 遗憾的是,这个错误是由快速奔腾CPU引起的,我在互联网上发现了一个可以解决错误的补丁。 (www.filewatcher.com/m/bp7patch.zip.62550-0.html)现在另一个问题是,当我跟踪代码时,它在尝试执行RxWait时执行时会挂起'while not odd(port[RXTX + 5]过程;'

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 }

3 个答案:

答案 0 :(得分:2)

据我记得(超过12年前),CRT单元在Pentium CPU方面遇到了问题,并将该分区归零。那天我正在使用Turbo Pascal 7。我的意思是它可能不是你的编码错误,而只是CRT单元本身。

答案 1 :(得分:0)

老问题我知道,但还有另一种方法来编写Turbo Pascal代码,而不会引起臭名昭着的RTE 200错误的愤怒。 FreePascal(www.freepascal.org)完全兼容TP7,可在许多操作系统下运行,包括DOS,Windows和Linux。

希望这有帮助!

答案 2 :(得分:0)

我解决了将执行上限设置为 20%的问题。因此处理器可能在那些日子里的速度和预期的一样慢。你可以玩百分比,直到错误消失

此致