Changeset 11 for trunk/Disassembler.pas


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.