Changeset 11


Ignore:
Timestamp:
Apr 20, 2026, 11:55:57 PM (6 days ago)
Author:
chronos
Message:
  • Added: Show comments in disassembled addresses.
  • Fixed: Stepping in code.
  • Modified: Show more registers in CPU view.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r6 r11  
    5151  private
    5252    LastPc: Word;
     53    procedure DoChangePC(Address: Word);
    5354  public
    5455    FormMain: TFormMain;
     
    180181    FormDisassembler := TFormDisassembler.Create(nil);
    181182    FormDisassembler.Disassembler.Memory := SharpMz800.MappedMemory;
     183    FormDisassembler.OnChangePC := DoChangePC;
    182184    SharpMz800.OnMemoryMappingChange := FormDisassembler.Disassemble;
    183185  end;
     
    234236end;
    235237
     238procedure TCore.DoChangePC(Address: Word);
     239begin
     240  SharpMz800.Cpu.PC := Address;
     241end;
     242
    236243procedure TCore.UpdateDisassemblerPos;
    237244begin
  • trunk/Disassembler.pas

    r10 r11  
    1616    Name: string;
    1717    Parameters: string;
     18    Comment: string;
    1819    constructor Create;
    1920    procedure AddOpcode(Data: Byte);
     
    4142  end;
    4243
     44  TComment = record
     45    Address: Word;
     46    Text: string;
     47  end;
     48
    4349
    4450implementation
     51
     52const
     53  Comments: array[0..16] of TComment = (
     54    (Address: $6; Text: 'LETNL (Moves the cursor to the beginning of the next line.)'),
     55    (Address: $c; Text: 'PRNTS (Display a space at the cursor position.)'),
     56    (Address: $12; Text: 'PRNTS (Display a character.)'),
     57    (Address: $15; Text: 'MSG (Displays a message.)'),
     58    (Address: $30; Text: 'MELDY'),
     59    (Address: $3e; Text: 'BELL'),
     60    (Address: $41; Text: 'XTEMP (Sets the music tempo.)'),
     61    (Address: $44; Text: 'MSTA (Generates a continuous sound of the specified frequency.)'),
     62    (Address: $309; Text: 'Init 8253 counters.'),
     63    (Address: $3da; Text: 'ASC (Loads the ASCII character.)'),
     64    (Address: $3f9; Text: 'HEX (Converts the 8 data bits stored in the ACC into a hexadecimal number.)'),
     65    (Address: $410; Text: 'HLHEX (Converts a string of 4 ASCII characters into a hexadecimal number and loads it in the HL register.)'),
     66    (Address: $41f; Text: '2HEX (Converts a string of 2 ASCII characters into a hexadecimal number and loads it into the ACC.)'),
     67    (Address: $73e; Text: 'Init 8255 PIO.'),
     68    (Address: $e414; Text: 'Delay'),
     69    (Address: $e800; Text: 'Cold start'),
     70    (Address: $e813; Text: 'Base init.')
     71  );
     72
     73function SearchComment(Address: Word): string;
     74var
     75  I: Integer;
     76begin
     77  I := 0;
     78  while (I <= High(Comments)) and (Comments[I].Address <> Address) do Inc(I);
     79  if I <= High(Comments) then Result := Comments[I].Text
     80    else Result := '';
     81end;
    4582
    4683{ TDecodedInstructions }
     
    96133  InstructionInfo: TInstructionInfo;
    97134  DecodedInstruction: TDecodedInstruction;
     135  DestAddress: Longint;
    98136begin
    99137  Memory.Position := 0;
     
    180218      end;
    181219    end;
     220
     221    DecodedInstruction.Comment := SearchComment(DecodedInstruction.Address);
     222    if DecodedInstruction.Comment = '' then begin
     223      if DecodedInstruction.Name = 'JP' then
     224        if TryStrToInt('$' + DecodedInstruction.Parameters, DestAddress) then begin
     225          DecodedInstruction.Comment := SearchComment(DestAddress);
     226          if DecodedInstruction.Comment <> '' then DecodedInstruction.Comment := 'Jump to ' + DecodedInstruction.Comment;
     227        end;
     228      if DecodedInstruction.Name = 'CALL' then
     229        if TryStrToInt('$' + DecodedInstruction.Parameters, DestAddress) then begin
     230          DecodedInstruction.Comment := SearchComment(DestAddress);
     231          if DecodedInstruction.Comment <> '' then DecodedInstruction.Comment := 'Call to ' + DecodedInstruction.Comment;
     232        end;
     233    end;
    182234    DecodedInstructions.Add(DecodedInstruction);
    183235  end;
  • trunk/Forms/FormCpu.lfm

    r2 r11  
    11object FormCpu: TFormCpu
    22  Left = 834
    3   Height = 438
     3  Height = 657
    44  Top = 501
    5   Width = 476
     5  Width = 274
    66  Caption = 'CPU'
    7   ClientHeight = 438
    8   ClientWidth = 476
     7  ClientHeight = 657
     8  ClientWidth = 274
    99  DesignTimePPI = 144
    10   LCLVersion = '2.2.6.0'
     10  LCLVersion = '4.6.0.0'
    1111  object GroupBox1: TGroupBox
    1212    Left = 22
    13     Height = 370
     13    Height = 546
    1414    Top = 22
    1515    Width = 230
    1616    Caption = 'Registers'
    17     ClientHeight = 343
     17    ClientHeight = 519
    1818    ClientWidth = 228
    1919    TabOrder = 0
    2020    object ValueListEditor1: TValueListEditor
    2121      Left = 16
    22       Height = 323
     22      Height = 499
    2323      Top = 5
    2424      Width = 192
    25       FixedCols = 0
     25      Anchors = [akTop, akLeft, akRight, akBottom]
    2626      RowCount = 2
    2727      TabOrder = 0
  • trunk/Forms/FormCpu.pas

    r9 r11  
    3535  ValueListEditor1.Values['PC'] := IntToHex(Cpu.PC, 4);
    3636  ValueListEditor1.Values['SP'] := IntToHex(Cpu.SP, 4);
     37  ValueListEditor1.Values['IX'] := IntToHex(Cpu.IX, 4);
     38  ValueListEditor1.Values['IY'] := IntToHex(Cpu.IY, 4);
     39  ValueListEditor1.Values['R'] := IntToHex(Cpu.RegR, 2);
     40  ValueListEditor1.Values['I'] := IntToHex(Cpu.RegI, 2);
     41  ValueListEditor1.Values['IM'] := IntToStr(Cpu.InterruptMode);
     42  ValueListEditor1.Values['EI'] := IntToStr(Byte(Cpu.InterruptEnabled));
     43  ValueListEditor1.Values['Cycles'] := IntToStr(Cpu.Cycles);
    3744  ValueListEditor1.Values['Ticks'] := IntToStr(Cpu.Ticks);
    3845end;
  • trunk/Forms/FormDisassembler.lfm

    r5 r11  
    3434      item
    3535        Caption = 'Parameters'
    36         Width = 691
     36        Width = 100
     37      end   
     38      item
     39        Caption = 'Comment'
     40        Width = 591
    3741      end>
    3842    OwnerData = True
     43    PopupMenu = PopupMenu1
    3944    ReadOnly = True
    4045    RowSelect = True
     
    4348    OnData = ListView1Data
    4449  end
     50  object PopupMenu1: TPopupMenu
     51    Left = 433
     52    Top = 343
     53    object MenuItemSetAddress: TMenuItem
     54      Caption = 'Set PC to address'
     55      OnClick = MenuItemSetAddressClick
     56    end
     57  end
    4558end
  • trunk/Forms/FormDisassembler.pas

    r6 r11  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls,
    7   ExtCtrls, Disassembler;
     7  ExtCtrls, Menus, Disassembler;
    88
    99type
     10  TChangePCEvent = procedure (Address: Word) of object;
    1011
    1112  { TFormDisassembler }
     
    1314  TFormDisassembler = class(TForm)
    1415    ListView1: TListView;
     16    MenuItemSetAddress: TMenuItem;
     17    PopupMenu1: TPopupMenu;
    1518    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    1619    procedure FormCreate(Sender: TObject);
     
    1821    procedure FormShow(Sender: TObject);
    1922    procedure ListView1Data(Sender: TObject; Item: TListItem);
     23    procedure MenuItemSetAddressClick(Sender: TObject);
     24  private
     25    FOnChangePC: TChangePCEvent;
     26    procedure DoChangePC(Address: Word);
    2027  public
    2128    Disassembler: TDisassembler;
     
    2330    procedure SelectAddress(Address: Word);
    2431    procedure ReloadList;
     32    property OnChangePC: TChangePCEvent read FOnChangePC write FOnChangePC;
    2533  end;
    2634
     
    6472    Item.SubItems.Add(Name);
    6573    Item.SubItems.Add(Parameters);
     74    Item.SubItems.Add(Comment);
    6675  end;
    6776end;
    6877
    69 procedure TFormDisassembler.Disassemble;
     78procedure TFormDisassembler.MenuItemSetAddressClick(Sender: TObject);
     79begin
     80  if Assigned(ListView1.Selected) then begin
     81    DoChangePC(TDecodedInstruction(ListView1.Selected.Data).Address);
     82    SelectAddress(TDecodedInstruction(ListView1.Selected.Data).Address);
     83  end;
     84end;
     85
     86procedure TFormDisassembler.Disassemble(Sender: TObject);
    7087begin
    7188  Disassembler.Disassemble;
    7289  ReloadList;
     90end;
     91
     92procedure TFormDisassembler.DoChangePC(Address: Word);
     93begin
     94  if Assigned(FOnChangePC) then FOnChangePC(Address);
    7395end;
    7496
  • trunk/Z80/Z80.pas

    r10 r11  
    818818    Memory: TMemory;
    819819    Ticks: Cardinal;
     820    Cycles: Cardinal;
    820821    InterruptEnabled: Boolean;
    821822    InterruptMode: Byte;
     
    851852    Cpu.Step;
    852853    if Cpu.DebugMode <> dmNone then begin
    853       if Cpu.DebugMode = dmStepIn then Terminate;
    854       if (Cpu.DebugMode = dmStopAddress) and (Cpu.DebugStopAddress = Cpu.PC) then
     854      if Cpu.DebugMode = dmStepIn then begin
     855        Cpu.DebugMode := dmNone;
    855856        Terminate;
    856       Cpu.DebugMode := dmNone;
     857      end;
     858      if (Cpu.DebugMode = dmStopAddress) and (Cpu.DebugStopAddress = Cpu.PC) then begin
     859        Cpu.DebugMode := dmNone;
     860        Terminate;
     861      end;
     862      if Cpu.DebugMode = dmStepOver then begin
     863        Cpu.DebugMode := dmNone;
     864        Terminate;
     865      end;
    857866    end;
    858867  end;
Note: See TracChangeset for help on using the changeset viewer.