gpt4 book ai didi

turbo-pascal - 如何解决 "Error 200: Division by zero"?

转载 作者:行者123 更新时间:2023-12-02 01:53:14 24 4
gpt4 key购买 nike

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

-Turbo Pascal 7.0、Free DOS 1.1、Virtual Box 4.3.6、Windows XP Service Pack 3 主机- 不幸的是,这个错误是由快速的奔腾 CPU 引起的,我在互联网上找到了一个可以解决这个错误的补丁。 ( www.filewatcher.com/m/bp7patch.zip.62550-0.html ) 现在另一个问题是,当我跟踪代码时,它在尝试执行 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 }

最佳答案

据我所知(超过 12 年前),CRT 单元在奔腾 CPU 方面存在问题,并给出除零错误。那些日子我正在使用 Turbo Pascal 7。我的意思是,这可能不是您的编码错误,而只是 CRT 单元本身。

关于turbo-pascal - 如何解决 "Error 200: Division by zero"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21647352/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com