Changeset 12
- Timestamp:
- Apr 21, 2026, 11:04:26 AM (6 days ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Core.lfm (modified) (1 diff)
-
Core.pas (modified) (3 diffs)
-
Disassembler.pas (modified) (2 diffs)
-
Forms/FormDisassembler.lfm (modified) (1 diff)
-
Forms/FormDisassembler.pas (modified) (8 diffs)
-
Z80/Z80.pas (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Core.lfm
r6 r12 44 44 Caption = 'Run to cursor' 45 45 ShortCut = 115 46 OnExecute = ARunToCursorExecute 46 47 end 47 48 object APause: TAction -
trunk/Core.pas
r11 r12 37 37 procedure AResetExecute(Sender: TObject); 38 38 procedure ARunExecute(Sender: TObject); 39 procedure ARunToCursorExecute(Sender: TObject); 39 40 procedure AStepInExecute(Sender: TObject); 40 41 procedure AStepOutExecute(Sender: TObject); … … 139 140 end; 140 141 142 procedure TCore.ARunToCursorExecute(Sender: TObject); 143 begin 144 SharpMz800.Cpu.DebugMode := dmStopAddress; 145 SharpMz800.Cpu.DebugStopAddress := FormDisassembler.GetCurrentAddress; 146 SharpMz800.Cpu.Running := True; 147 UpdateInterface; 148 end; 149 141 150 procedure TCore.AStepInExecute(Sender: TObject); 142 151 begin … … 182 191 FormDisassembler.Disassembler.Memory := SharpMz800.MappedMemory; 183 192 FormDisassembler.OnChangePC := DoChangePC; 193 FormDisassembler.Cpu := SharpMz800.Cpu; 184 194 SharpMz800.OnMemoryMappingChange := FormDisassembler.Disassemble; 185 195 end; -
trunk/Disassembler.pas
r11 r12 51 51 52 52 const 53 Comments: array[0..16] of TComment = ( 53 Comments: array[0..35] of TComment = ( 54 (Address: $3; Text: 'GETL (Reads one line of data from the keyboard and stores it in the memory area starting at the address in the DE register.)'), 54 55 (Address: $6; Text: 'LETNL (Moves the cursor to the beginning of the next line.)'), 56 (Address: $9; Text: 'Line feed'), 55 57 (Address: $c; Text: 'PRNTS (Display a space at the cursor position.)'), 58 (Address: $f; Text: 'Move cursor to next tab position'), 56 59 (Address: $12; Text: 'PRNTS (Display a character.)'), 57 60 (Address: $15; Text: 'MSG (Displays a message.)'), 61 (Address: $18; Text: 'IOSVC'), 62 (Address: $1b; Text: 'GETKEY (Reads a character code (ASCII) from the keyboard.)'), 63 (Address: $1e; Text: 'BRKEY (Checks whether the I SHIFT I and I BREAK I keys are both being pressed.)'), 58 64 (Address: $30; Text: 'MELDY'), 65 (Address: $33; Text: 'TIMST (Sets and starts the built-in clock.)'), 66 (Address: $3b; Text: 'TIMRD (Reads the built-in clock and returns the time.'), 59 67 (Address: $3e; Text: 'BELL'), 60 68 (Address: $41; Text: 'XTEMP (Sets the music tempo.)'), 61 69 (Address: $44; Text: 'MSTA (Generates a continuous sound of the specified frequency.)'), 62 (Address: $309; Text: 'Init 8253 counters.'), 70 (Address: $47; Text: 'MSTP (Stops the sound generated with the CALL MSTA subroutine.)'), 71 (Address: $308; Text: 'Init 8253 counters.'), 63 72 (Address: $3da; Text: 'ASC (Loads the ASCII character.)'), 64 73 (Address: $3f9; Text: 'HEX (Converts the 8 data bits stored in the ACC into a hexadecimal number.)'), … … 66 75 (Address: $41f; Text: '2HEX (Converts a string of 2 ASCII characters into a hexadecimal number and loads it into the ACC.)'), 67 76 (Address: $73e; Text: 'Init 8255 PIO.'), 77 (Address: $9b3; Text: '??KEY (Blinks the cursor to prompt for key input.)'), 78 (Address: $a32; Text: 'Something with 8255 PIO.'), 79 (Address: $bb9; Text: '?ADCN (Converts ASCII codes into display codes.)'), 80 (Address: $bce; Text: '?DACN (Converts display codes into ASCII codes.)'), 81 (Address: $da6; Text: '?BLNK (Detects the vertical blanking period.)'), 82 (Address: $ddc; Text: '?DPCT (Controls display.)'), 83 (Address: $fb1; Text: '?POINT (Loads the current cursor location into the HL register.)'), 84 (Address: $fd8; Text: 'Write FF to (HL) B times.'), 85 (Address: $1171; Text: 'Cursor pos.'), 86 (Address: $1172; Text: 'Cursor pos.'), 68 87 (Address: $e414; Text: 'Delay'), 69 88 (Address: $e800; Text: 'Cold start'), -
trunk/Forms/FormDisassembler.lfm
r11 r12 49 49 end 50 50 object PopupMenu1: TPopupMenu 51 Left = 433 52 Top = 343 51 OnPopup = PopupMenu1Popup 52 Left = 440 53 Top = 352 53 54 object MenuItemSetAddress: TMenuItem 54 55 Caption = 'Set PC to address' 55 56 OnClick = MenuItemSetAddressClick 56 57 end 58 object MenuItemAddBreakPoint: TMenuItem 59 Caption = 'Add break point' 60 OnClick = MenuItemAddBreakPointClick 61 end 62 object MenuItemRemoveBreakPoint: TMenuItem 63 Caption = 'Remove break point' 64 OnClick = MenuItemRemoveBreakPointClick 65 end 57 66 end 58 67 end -
trunk/Forms/FormDisassembler.pas
r11 r12 5 5 uses 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, 7 ExtCtrls, Menus, Disassembler ;7 ExtCtrls, Menus, Disassembler, Z80; 8 8 9 9 type 10 T ChangePCEvent = procedure (Address: Word) of object;10 TAddressEvent = procedure (Address: Word) of object; 11 11 12 12 { TFormDisassembler } … … 14 14 TFormDisassembler = class(TForm) 15 15 ListView1: TListView; 16 MenuItemRemoveBreakPoint: TMenuItem; 17 MenuItemAddBreakPoint: TMenuItem; 16 18 MenuItemSetAddress: TMenuItem; 17 19 PopupMenu1: TPopupMenu; … … 21 23 procedure FormShow(Sender: TObject); 22 24 procedure ListView1Data(Sender: TObject; Item: TListItem); 25 procedure MenuItemAddBreakPointClick(Sender: TObject); 26 procedure MenuItemRemoveBreakPointClick(Sender: TObject); 23 27 procedure MenuItemSetAddressClick(Sender: TObject); 28 procedure PopupMenu1Popup(Sender: TObject); 24 29 private 25 FOnChangePC: TChangePCEvent; 30 FOnAddBreakPoint: TAddressEvent; 31 FOnChangePC: TAddressEvent; 26 32 procedure DoChangePC(Address: Word); 33 procedure DoAddBreakPoint(Address: Word); 27 34 public 35 Cpu: TCpuZ80; 28 36 Disassembler: TDisassembler; 29 37 procedure Disassemble(Sender: TObject); 30 38 procedure SelectAddress(Address: Word); 31 39 procedure ReloadList; 32 property OnChangePC: TChangePCEvent read FOnChangePC write FOnChangePC; 40 function GetCurrentAddress: Word; 41 property OnChangePC: TAddressEvent read FOnChangePC write FOnChangePC; 42 property OnAddBreakPoint: TAddressEvent read FOnAddBreakPoint write FOnAddBreakPoint; 33 43 end; 34 44 … … 64 74 65 75 procedure TFormDisassembler.ListView1Data(Sender: TObject; Item: TListItem); 76 var 77 BreakPoint: string; 66 78 begin 67 79 if Item.Index < Disassembler.DecodedInstructions.Count then 68 80 with TDecodedInstruction(Disassembler.DecodedInstructions[Item.Index]) do begin 69 Item.Caption := IntToHex(Address, 4); 81 if Cpu.BreakPoints.Contains(Address) then BreakPoint := ' @' 82 else BreakPoint := ''; 83 Item.Caption := IntToHex(Address, 4) + BreakPoint; 70 84 Item.Data := Disassembler.DecodedInstructions[Item.Index]; 71 85 Item.SubItems.Add(GetOpcodesText); … … 76 90 end; 77 91 92 procedure TFormDisassembler.MenuItemAddBreakPointClick(Sender: TObject); 93 begin 94 if Assigned(ListView1.Selected) then begin 95 Cpu.BreakPoints.Add(TDecodedInstruction(ListView1.Selected.Data).Address); 96 ReloadList; 97 end; 98 end; 99 100 procedure TFormDisassembler.MenuItemRemoveBreakPointClick(Sender: TObject); 101 begin 102 if Assigned(ListView1.Selected) then begin 103 Cpu.BreakPoints.Remove(TDecodedInstruction(ListView1.Selected.Data).Address); 104 ReloadList; 105 end; 106 end; 107 78 108 procedure TFormDisassembler.MenuItemSetAddressClick(Sender: TObject); 79 109 begin … … 81 111 DoChangePC(TDecodedInstruction(ListView1.Selected.Data).Address); 82 112 SelectAddress(TDecodedInstruction(ListView1.Selected.Data).Address); 113 end; 114 end; 115 116 procedure TFormDisassembler.PopupMenu1Popup(Sender: TObject); 117 begin 118 119 MenuItemSetAddress.Enabled := Assigned(ListView1.Selected); 120 if Assigned(ListView1.Selected) then begin 121 MenuItemRemoveBreakPoint.Enabled := Pos('@', ListView1.Selected.Caption) > 0; 122 MenuItemAddBreakPoint.Enabled := not MenuItemRemoveBreakPoint.Enabled; 123 end else begin 124 MenuItemRemoveBreakPoint.Enabled := False; 125 MenuItemAddBreakPoint.Enabled := False; 83 126 end; 84 127 end; … … 93 136 begin 94 137 if Assigned(FOnChangePC) then FOnChangePC(Address); 138 end; 139 140 procedure TFormDisassembler.DoAddBreakPoint(Address: Word); 141 begin 142 if Assigned(FOnAddBreakPoint) then FOnAddBreakPoint(Address); 95 143 end; 96 144 … … 124 172 end; 125 173 174 function TFormDisassembler.GetCurrentAddress: Word; 175 begin 176 if Assigned(ListView1.Selected) then 177 Result := TDecodedInstruction(ListView1.Selected.Data).Address 178 else Result := 0; 179 end; 180 126 181 end. 127 182 -
trunk/Z80/Z80.pas
r11 r12 4 4 5 5 uses 6 Classes, SysUtils, Memory, Base, Z80Instructions; 6 Classes, SysUtils, Memory, Base, Z80Instructions, Generics.Collections, 7 Generics.Defaults; 7 8 8 9 type … … 41 42 42 43 TDebugMode = (dmNone, dmStepIn, dmStepOut, dmStepOver, dmStopAddress); 44 45 { TBreakPoints } 46 47 TBreakPoints = class(TList<Word>) 48 private 49 function Comparer(constref Left, Right: Word): Integer; 50 public 51 function Contains(Address: Word): Boolean; 52 procedure AddNew(Address: Word); 53 end; 43 54 44 55 { TCpuZ80 } … … 821 832 InterruptEnabled: Boolean; 822 833 InterruptMode: Byte; 834 BreakPoints: TBreakPoints; 823 835 DebugMode: TDebugMode; 824 836 DebugStopAddress: Word; … … 851 863 while not Terminated do begin 852 864 Cpu.Step; 853 if Cpu.DebugMode <> dmNone then begin854 if Cpu.DebugMode = dmStepIn then begin855 Cpu.DebugMode := dmNone;856 Terminate;857 end;858 if (Cpu.DebugMode = dmStopAddress) and (Cpu.DebugStopAddress = Cpu.PC) then begin859 Cpu.DebugMode := dmNone;860 Terminate;861 end;862 if Cpu.DebugMode = dmStepOver then begin863 Cpu.DebugMode := dmNone;864 Terminate;865 end;866 end;867 865 end; 868 866 Cpu.FRunning := False; 867 end; 868 869 { TBreakPoints } 870 871 function TBreakPoints.Comparer(constref Left, Right: Word): Integer; 872 begin 873 if Left > Right then Result := 1 874 else if Left < Right then Result := -1 875 else Result := 0; 876 end; 877 878 function TBreakPoints.Contains(Address: Word): Boolean; 879 var 880 Index: SizeInt; 881 begin 882 if (Count > 0) and BinarySearch(Address, Index, TComparer<Word>.Construct(Comparer)) then begin 883 Result := True; 884 end else Result := False; 885 end; 886 887 procedure TBreakPoints.AddNew(Address: Word); 888 begin 889 Add(Address); 890 Sort; 869 891 end; 870 892 … … 5533 5555 end; 5534 5556 Ticks := Cardinal(Ticks + 1); 5557 5558 // Debugging 5559 if DebugMode <> dmNone then begin 5560 if DebugMode = dmStepIn then begin 5561 DebugMode := dmNone; 5562 FThread.Terminate; 5563 end; 5564 if (DebugMode = dmStopAddress) and (DebugStopAddress = PC) then begin 5565 DebugMode := dmNone; 5566 FThread.Terminate; 5567 end; 5568 if DebugMode = dmStepOver then begin 5569 DebugMode := dmNone; 5570 FThread.Terminate; 5571 end; 5572 end; 5573 if BreakPoints.Contains(PC) then begin 5574 DebugMode := dmNone; 5575 FThread.Terminate; 5576 end; 5535 5577 end; 5536 5578 … … 5550 5592 constructor TCpuZ80.Create; 5551 5593 begin 5594 BreakPoints := TBreakPoints.Create; 5552 5595 InitInstructions; 5553 5596 Reset; … … 5557 5600 begin 5558 5601 Running := False; 5602 FreeAndNil(BreakPoints); 5559 5603 inherited; 5560 5604 end;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/mzxemu/chrome/site/your_project_logo.png)