看不懂这个错误大家看一看,
Project 123.exe raised exception class EAccessViolation with
message 'Access violation at address 00404660 in module '123.exe'.
Read of address 0000001A'.
Process stopped.Use Step or Run to continue.
不知道犯了什么错误,Help!
Project 123.exe raised exception class EAccessViolation with
message 'Access violation at address 00404660 in module '123.exe'.
Read of address 0000001A'.
Process stopped.Use Step or Run to continue.
不知道犯了什么错误,Help!
procedure CacheRun();
var
Alength,I,J,K: Integer;
InfStr,TagStr,IndexStr,AllStr: string;
Tagint,Indexint: Longint;
match: Boolean; //是否有匹配
NotFull: Boolean; //有空的映射块
Swapint: Integer;//被替换的块号
TimeStrFirIn,TimeStrLRU: string;
begin
if WXL = False then
begin
Alength := Length(AddrArray);
for I := 0 to Alength-1 do
begin
AllStr := inttobin(AddrArray[I].Addr,26);
TagStr := Copy(AllStr,1,x);
IndexStr := Copy(AllStr,x+1,y);
Tagint := bintoint(TagStr);
Indexint := bintoint(IndexStr);
match := False;
NotFull := False;
for J := Indexint*n+0 to Indexint*n+n-1 do
begin
if(MLBArray[J].tag = Tagint)and(MLBArray[J].YXW = True)then
begin
match := True;
HCount := HCount+1;
MLBArray[J].TimeStrRec := TimeToStr(Time);
AddrArray[I].Hit := True;
break;
end;
if MLBArray[J].tag = -1 then
NotFull := True;
end;
if match = False then
begin
if NotFull = True then
begin
for K := Indexint*n+0 to Indexint*n+n-1 do
if MLBArray[K].tag = -1 then
begin
MLBArray[K].tag := Tagint;
MLBArray[K].TimeStrIn := TimeToStr(Time);
MLBArray[K].TimeStrRec := MLBArray[K].TimeStrIn;
break;
end;
end;
if NotFull = False then
begin
if Swap = 1 then
begin
Swapint := Indexint*n+Random(n);
end;
if Swap = 2 then
begin
TimeStrFirIn := TimeToStr(time;) for K:= Indexint*n+0 to Indexint*n+n-1do
if AnsiCompareText(MLBArray[K].TimeStrIn,TimeStrFirIn)<0 then
begin
TimeStrFirIn := MLBArray[K].TimeStrIn;
Swapint := K;
end; end;
if Swap = 3 then
begin
TimeStrLRU := TimeToSt(time); for K:= Indexint*n+0 to Indexint*n+n-1 do
if AnsiCompareText(MLBArray[K].TimeStrRec,TimeStrLRU)<0 then
begin
TimeStrLRU := MLBArray[K].TimeStrRec;
Swapint := K;
end;
end;
MLBArray[Swapint].tag := Tagint;
MLBArray[Swapint].TimeStrIn := TimeToStr(Time);
MLBArray[Swapint].TimeStrRec := MLBArray[Swapint].TimeStrIn;
end;
end; end; end; HaveRun := True;
HitStatistic();
ComputeRes();
InfStr := '模拟完成,请通过ViewResult菜单查看模拟结果!';
MessageDlg(InfStr,mtInformation,[mbOK],0);end;
TAddrItem = record
Addr : Longint;
Hit : Boolean;
end;
TMLBItem = record
tag : Longint;
YXW : Boolean;
TimeStrIn : string;{调入时间字符串}
TimeStrRec : string;{最近访问时间字符串}
end;AddrArray : array of TAddrItem;
MLBArray : array of TMLBItem;
procedure CacheRun();
var
Alength,I,J,K: Integer;
InfStr,TagStr,IndexStr,AllStr: string;
Tagint,Indexint: Longint;
match: Boolean; //是否有匹配
NotFull: Boolean; //有空的映射块
Swapint: Integer;//被替换的块号
TimeStrFirIn,TimeStrLRU: string;
begin
if WXL = False then
begin
Alength := Length(AddrArray);
for I := 0 to Alength-1 do
begin
AllStr := inttobin(AddrArray[I].Addr,26);
TagStr := Copy(AllStr,1,x);
IndexStr := Copy(AllStr,x+1,y);
Tagint := bintoint(TagStr);
Indexint := bintoint(IndexStr);
match := False;
NotFull := False;
for J := Indexint*n+0 to Indexint*n+n-1 do
begin
if(MLBArray[J].tag = Tagint)and
(MLBArray[J].YXW = True)then
begin
match := True;
HCount := HCount+1;
MLBArray[J].TimeStrRec := TimeToStr(Time);
AddrArray[I].Hit := True;
break;
end;
if MLBArray[J].tag = -1 then
NotFull := True;
end;
if match = False then
begin
if NotFull = True then
begin
for K := Indexint*n+0 to Indexint*n+n-1 do
if MLBArray[K].tag = -1 then
begin
MLBArray[K].tag := Tagint;
MLBArray[K].TimeStrIn
:= TimeToStr(Time);
MLBArray[K].TimeStrRec
:= MLBArray[K].TimeStrIn;
break;
end;
end;
if NotFull = False then
begin
if Swap = 1 then
begin
Swapint := Indexint*n+Random(n);
end;
if Swap = 2 then
begin
TimeStrFirIn := TimeToStr(Time);
for K:= Indexint*n+0 to Indexint*n+n-1 do
if AnsiCompareText(MLBArray[K].TimeStrIn,TimeStrFirIn)<0 then
begin
TimeStrFirIn
:= MLBArray[K].TimeStrIn;
Swapint := K;
end; end;
if Swap = 3 then
begin
TimeStrLRU := TimeToStr(Time);
for K:= Indexint*n+0 to Indexint*n+n-1 do
if AnsiCompareText(MLBArray[K].TimeStrRec,TimeStrLRU)<0 then
begin
TimeStrLRU
:= MLBArray[K].TimeStrRec;
Swapint := K;
end;
end;
MLBArray[Swapint].tag := Tagint;
MLBArray[Swapint].TimeStrIn := TimeToStr(Time);
MLBArray[Swapint].TimeStrRec
:= MLBArray[Swapint].TimeStrIn;
end;
end; end; end; HaveRun := True;
HitStatistic();
ComputeRes();
InfStr := '模拟完成,请通过ViewResult菜单查看模拟结果!';
MessageDlg(InfStr,mtInformation,[mbOK],0);end;
谢谢
不过有好多种可能,
TimeStrIn : string;{调入时间字符串}
TimeStrRec : string;{最近访问时间字符串}的赋值、比较有关
我将TimeStrIn的类型改为TDataTime后,发现错误:Project Cache.exe raised exception class EInvalidOp with message 'Invalid
floating point operation'. Process stopped. Use Step or Run to continue.对应这行代码:
if CompareDate(MLBArray[K].TimeRec,TimeLRU)=-1 then