⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbgpliki.pas

📁 Borland Pascal写的8051单片机模拟仿真器。内有源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:

procedure WczytajRAM(Okno:HWnd);
const DefExt = 'bin';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(24));
  StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_FileMustExist or ofn_HideReadOnly;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetOpenFileName(OpenFN) then Exit;
  WczytajAutoRAM(Okno,FileName,true);
end;

procedure WczytajAutoRAM(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
  Plik:string;
  Info:HWnd;
  code,b:integer;
  d1:longint;
  off:word;
  we:file;
begin
  Plik:=StrPas(nazwa);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  Assign(we,Plik);
  {$I-} Reset(we,1); {$I+}
  if IOResult<>0 then Exit;
  Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
  if longint(off)+FileSize(we)>65536 then d1:=65536-off else d1:=FileSize(we);
  BlockRead(we,Mem[selRAM:off],d1,code);
  Close(we);
  DestroyWindow(Info);
  OdrysujWszystkie;
  if dodac then DodajDoListyPlikow(nazwa,'R');
end;

procedure ZapiszRAM(Okno:HWnd);
const DefExt = 'bin';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
  Plik:string;
  Info:HWnd;
  code,b:integer;
  off,dlug:word;
  d1:longint;
  bajt:byte;
  wy:file;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(24));
  StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  b:=PokazDialog('DLUGOSC',@FunDlugosc);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,dlug,code);
  if code<>0 then Exit;
  if dlug=0 then Exit;
  if adrost then dlug:=dlug-off+1;
  Assign(wy,Plik);
  {$I-} Rewrite(wy,1); {$I+}
  if IOResult<>0 then Exit;
  Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
  if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
  BlockWrite(wy,Mem[selRAM:off],d1,code);
  Close(wy);
  DestroyWindow(Info);
  DodajDoListyPlikow(FileName,'R');
  OdrysujWszystkie;
end;

procedure WczytajAutoRAMhex(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;

procedure WczytajRAMhex(Okno:HWnd);
const DefExt = 'hex';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
begin
  FillChar(FileName,256,0);
  FillChar(Filter,24,0);
  StrCopy(Filter,Napis1(22));
  StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
  FillChar(OpenFN,SizeOf(TOpenFileName),0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_FileMustExist or ofn_HideReadOnly;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetOpenFileName(OpenFN) then Exit;
  WczytajAutoRAMhex(Okno,FileName,true);
end;

procedure WczytajAutoRAMhex(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
  Info:HWnd;
  Plik,linia:string;
  off,radr:word;
  bajt,rlen,rtyp,x,n:byte;
  we:text;
begin
  Plik:=StrPas(nazwa);
  Assign(we,Plik);
  {$I-} Reset(we); {$I+}
  if IOResult<>0 then Exit;
  rtyp:=0;
  off:=65535;
  Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
  repeat
    Readln(we,linia);
    if linia[1]=':' then
    begin
      rlen:=HEXtoB(Copy(linia,2,2));
      radr:=HEXtoW(Copy(linia,4,4));
      rtyp:=HEXtoB(Copy(linia,8,2));
      if off=65535 then off:=radr;
      if rtyp=0 then
      begin
        x:=10;
        for n:=1 to rlen do
        begin
          bajt:=HEXtoB(Copy(linia,x,2));
          Mem[selRAM:radr]:=bajt;
          Inc(x,2);
          Inc(radr);
        end;
      end;
    end;
  until (rtyp=1) or Eof(we);
  Close(we);
  DestroyWindow(Info);
  OdrysujWszystkie;
  if dodac then DodajDoListyPlikow(nazwa,'A');
end;

procedure ZapiszRAMhex(Okno:HWnd);
const DefExt = 'hex';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
  Plik:string;
  linia:string[80];
  Info:HWnd;
  off,radr:word;
  d1,dlug:longint;
  b,code:integer;
  rsum,rlen,n:byte;
  wy:text;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(22));
  StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  b:=PokazDialog('DLUGOSC',@FunDlugosc);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,dlug,code);
  if code<>0 then Exit;
  if dlug=0 then Exit;
  if adrost then dlug:=dlug-off+1;
  Assign(wy,Plik);
  {$I-} Rewrite(wy); {$I+}
  if IOResult<>0 then Exit;
  if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
  Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
  radr:=off;
  repeat
    rsum:=0;
    if d1>32 then rlen:=32 else rlen:=d1;
    linia:=':'+BtoHEX(rlen)+WtoHEX(radr)+'00';
    for n:=0 to rlen-1 do
    begin
      linia:=linia+BtoHEX(Mem[selRAM:radr]);
      rsum:=rsum+Mem[selRAM:radr];
      Inc(radr);
      Dec(d1);
    end;
    linia:=linia+BtoHEX(byte(0)-rsum);
    Writeln(wy,linia);
  until d1=0;
  Writeln(wy,':00000001FF');
  Close(wy);
  DestroyWindow(Info);
  DodajDoListyPlikow(FileName,'A');
  OdrysujWszystkie;
end;

procedure WczytajAutoRAMInt(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;

procedure WczytajRAMInt(Okno:HWnd);
const DefExt = 'bin';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(24));
  StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_FileMustExist or ofn_HideReadOnly;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetOpenFileName(OpenFN) then Exit;
  WczytajAutoRAMInt(Okno,FileName,true);
end;

procedure WczytajAutoRAMInt(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
  Plik:string;
  Info:HWnd;
  code,b:integer;
  d1:longint;
  off:word;
  we:file;
begin
  Plik:=StrPas(nazwa);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  if off>255 then
  begin
    MessageBeep(mb_IconHand);
    BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
    Exit;
  end;
  Assign(we,Plik);
  {$I-} Reset(we,1); {$I+}
  if IOResult<>0 then Exit;
  Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
  if longint(off)+FileSize(we)>256 then d1:=256-off else d1:=FileSize(we);
  BlockRead(we,Mem[selRAMInt:off],d1,code);
  Close(we);
  DestroyWindow(Info);
  OdrysujWszystkie;
  if dodac then DodajDoListyPlikow(nazwa,'I');
end;

procedure ZapiszRAMInt(Okno:HWnd);
const DefExt = 'bin';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
  Plik:string;
  Info:HWnd;
  code,b:integer;
  off,dlug:word;
  d1:longint;
  bajt:byte;
  wy:file;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(24));
  StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  if off>255 then
  begin
    MessageBeep(mb_IconHand);
    BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
    Exit;
  end;
  b:=PokazDialog('DLUGOSC',@FunDlugosc);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,dlug,code);
  if code<>0 then Exit;
  if dlug=0 then Exit;
  if adrost then dlug:=dlug-off+1;
  Assign(wy,Plik);
  {$I-} Rewrite(wy,1); {$I+}
  if IOResult<>0 then Exit;
  Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
  if longint(off)+dlug>256 then d1:=256-off else d1:=dlug;
  BlockWrite(wy,Mem[selRAMInt:off],d1,code);
  Close(wy);
  DestroyWindow(Info);
  DodajDoListyPlikow(FileName,'I');
  OdrysujWszystkie;
end;

procedure WczytajAutoRAMInthex(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;

procedure WczytajRAMInthex(Okno:HWnd);
const DefExt = 'hex';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
begin
  FillChar(FileName,256,0);
  FillChar(Filter,24,0);
  StrCopy(Filter,Napis1(22));
  StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
  FillChar(OpenFN,SizeOf(TOpenFileName),0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_FileMustExist or ofn_HideReadOnly;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetOpenFileName(OpenFN) then Exit;
  WczytajAutoRAMInthex(Okno,FileName,true);
end;

procedure WczytajAutoRAMInthex(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
  Info:HWnd;
  Plik,linia:string;
  off,radr:word;
  bajt,rlen,rtyp,x,n:byte;
  we:text;
begin
  Plik:=StrPas(nazwa);
  Assign(we,Plik);
  {$I-} Reset(we); {$I+}
  if IOResult<>0 then Exit;
  rtyp:=0;
  off:=65535;
  Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
  repeat
    Readln(we,linia);
    if linia[1]=':' then
    begin
      rlen:=HEXtoB(Copy(linia,2,2));
      radr:=HEXtoW(Copy(linia,4,4));
      rtyp:=HEXtoB(Copy(linia,8,2));
      if off=65535 then off:=radr;
      if rtyp=0 then
      begin
        x:=10;
        for n:=1 to rlen do
        begin
          bajt:=HEXtoB(Copy(linia,x,2));
          Mem[selRAMInt:Lo(radr)]:=bajt;
          Inc(x,2);
          Inc(radr);
        end;
      end;
    end;
  until (rtyp=1) or Eof(we);
  Close(we);
  DestroyWindow(Info);
  OdrysujWszystkie;
  if dodac then DodajDoListyPlikow(nazwa,'N');
end;

procedure ZapiszRAMInthex(Okno:HWnd);
const DefExt = 'hex';
var
  OpenFN:TOpenFileName;
  Filter:array [0..23] of char;
  FileName:array [0..255] of char;
  Plik:string;
  linia:string[80];
  Info:HWnd;
  off,dlug,radr:word;
  b,code:integer;
  rsum,rlen,n:byte;
  wy:text;
begin
  FillChar(FileName,256,#0);
  FillChar(Filter,24,#0);
  StrCopy(Filter,Napis1(22));
  StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
  FillChar(OpenFN,SizeOf(TOpenFileName),#0);
  with OpenFN do
  begin
    hInstance     := HInstance;
    hwndOwner     := Okno;
    lpstrDefExt   := DefExt;
    lpstrFile     := FileName;
    lpstrFilter   := Filter;
    lpstrFileTitle:= nil;
    flags         := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
    lStructSize   := SizeOf(TOpenFileName);
    nFilterIndex  := 1;
    nMaxFile      := SizeOf(FileName);
  end;
  if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
  b:=PokazDialog('OFFSET',@FunOffset);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,off,code);
  if code<>0 then Exit;
  if off>255 then
  begin
    MessageBeep(mb_IconHand);
    BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
    Exit;
  end;
  b:=PokazDialog('DLUGOSC',@FunDlugosc);
  if b<>1 then Exit;
  if (Length(wynik)>4) or (wynik='') then Exit;
  Val('$'+wynik,dlug,code);
  if code<>0 then Exit;
  if dlug=0 then Exit;
  if adrost then dlug:=dlug-off+1;
  Assign(wy,Plik);
  {$I-} Rewrite(wy); {$I+}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -