Ignore:
Timestamp:
Apr 10, 2019, 4:00:46 PM (6 years ago)
Author:
chronos
Message:
  • Added: Keyboard console.
  • Added: Show Hello World! message.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4/UInstructionWriter.pas

    r170 r171  
    1919    procedure Write32(Value: DWord);
    2020    procedure Write64(Value: QWord);
     21    procedure WriteAddress(Value: TAddress);
     22    procedure WriteData(Value: QWord);
     23    procedure WriteString(Text: string);
    2124    procedure Nop;
    2225    procedure Halt;
    2326    procedure LoadConst(Reg: Byte; Value: QWord);
    2427    procedure Increment(Reg: Byte);
     28    procedure Decrement(Reg: Byte);
    2529    procedure Jump(Value: QWord);
     30    procedure JumpNotZero(Value: QWord);
    2631    procedure DataPrefix8;
    2732    procedure StoreMem(RegAddr, RegSrc: Byte);
     33    procedure LoadMem(RegDst, RegAddr: Byte);
     34    procedure Output(Port: TAddress; Reg: Byte);
     35    procedure Input(Reg: Byte; Port: TAddress);
     36    procedure Test(Reg: Byte);
    2837  end;
    2938
     
    4756  Write8(Byte(opLoadConst));
    4857  Write8(Reg);
    49   case Cpu.DataSize of
    50     bw8: Write8(Value);
    51     bw16: Write16(Value);
    52     bw32: Write32(Value);
    53     bw64: Write64(Value);
    54   end;
     58  WriteData(Value);
    5559end;
    5660
     
    6165end;
    6266
     67procedure TInstructionWriter.Decrement(Reg: Byte);
     68begin
     69  Write8(Byte(opDec));
     70  Write8(Reg);
     71end;
     72
    6373procedure TInstructionWriter.Jump(Value: QWord);
    6474begin
    6575  Write8(Byte(opJump));
    66   case Cpu.AddressSize of
    67     bw8: Write8(Value);
    68     bw16: Write16(Value);
    69     bw32: Write32(Value);
    70     bw64: Write64(Value);
    71   end;
     76  WriteAddress(Value);
     77end;
     78
     79procedure TInstructionWriter.JumpNotZero(Value: QWord);
     80begin
     81  Write8(Byte(opJumpNotZero));
     82  WriteAddress(Value);
    7283end;
    7384
     
    8293  Write8(RegAddr);
    8394  Write8(RegSrc);
     95end;
     96
     97procedure TInstructionWriter.LoadMem(RegDst, RegAddr: Byte);
     98begin
     99  Write8(Byte(opLoadMem));
     100  Write8(RegDst);
     101  Write8(RegAddr);
     102end;
     103
     104procedure TInstructionWriter.Output(Port: TAddress; Reg: Byte);
     105begin
     106  Write8(Byte(opOut));
     107  WriteAddress(Port);
     108  Write8(Reg);
     109end;
     110
     111procedure TInstructionWriter.Input(Reg: Byte; Port: TAddress);
     112begin
     113  Write8(Byte(opIn));
     114  Write8(Reg);
     115  WriteAddress(Port);
     116end;
     117
     118procedure TInstructionWriter.Test(Reg: Byte);
     119begin
     120  Write8(Byte(opTest));
     121  Write8(Reg);
     122end;
     123
     124procedure TInstructionWriter.WriteString(Text: string);
     125var
     126  I: Integer;
     127begin
     128  for I := 1 to Length(Text) do
     129    Write8(Ord(Text[I]));
    84130end;
    85131
     
    108154end;
    109155
     156procedure TInstructionWriter.WriteAddress(Value: TAddress);
     157begin
     158  case Cpu.AddressSize of
     159    bw8: Write8(Value);
     160    bw16: Write16(Value);
     161    bw32: Write32(Value);
     162    bw64: Write64(Value);
     163  end;
     164end;
     165
     166procedure TInstructionWriter.WriteData(Value: QWord);
     167begin
     168  case Cpu.DataSize of
     169    bw8: Write8(Value);
     170    bw16: Write16(Value);
     171    bw32: Write32(Value);
     172    bw64: Write64(Value);
     173  end;
     174end;
     175
    110176end.
    111177
Note: See TracChangeset for help on using the changeset viewer.