Changeset 168 for branches/virtcpu fixed int/UFormMain.pas
- Timestamp:
- Oct 16, 2018, 11:03:59 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtcpu fixed int/UFormMain.pas
r165 r168 16 16 Button1: TButton; 17 17 Button2: TButton; 18 LabelTicks: TLabel; 18 19 ListViewMemory: TListView; 19 20 ListViewRegisters: TListView; … … 57 58 var 58 59 LabelStart: Integer; 59 begin 60 LabelPrint: Integer; 61 LabelPrintBack: Integer; 62 R0: Integer; 63 R1: Integer; 64 R2: Integer; 65 R3: Integer; 66 R4: Integer; 67 begin 68 R0 := 0; 69 R1 := 1; 70 R2 := 2; 71 R3 := 3; 72 R4 := 4; 60 73 with InstructionWriter do begin 61 { AddNop;62 AddLdc(1, $ffff);63 AddLd(0, 1);64 AddLdc(2, $10);65 AddStm(2, 0);74 {NoOperation; 75 LoadConst(1, $ffff); 76 Load(0, 1); 77 LoadConst(2, $10); 78 StoreMemory(2, 0); 66 79 } 67 68 AddLdc(2, 0); 69 AddLdc(0, 0); 70 LabelStart := IP; 71 AddIn(1, 0); 72 AddOut(0, 1); 73 AddInc(2); 74 AddJump(LabelStart); 75 AddHalt; 80 LabelPrint := $100; 81 82 LoadConst(R2, 0); 83 LoadConst(R0, 0); 84 LoadConst(R4, Ord('a')); 85 LabelStart := IP; 86 Input(R1, 0); 87 Output(0, R1); 88 Subtract(R1, R4); 89 JumpZero(R1, LabelPrint); 90 LabelPrintBack := IP; 91 Increment(R2); 92 Jump(LabelStart); 93 Halt; 94 IP := LabelPrint; 95 LoadConst(R3, Ord('!')); 96 Output(0, R3); 97 Jump(LabelPrintBack) 76 98 end; 77 99 end; … … 122 144 procedure TForm1.ListViewRegistersData(Sender: TObject; Item: TListItem); 123 145 begin 124 if Item.Index < Length(Cpu.Registers) then begin 125 Item.Caption := 'R' + IntToStr(Item.Index); 126 Item.SubItems.Add(IntToHex(Cpu.Registers[Item.Index], 8)); 146 if Item.Index < Length(Cpu.Registers) + 1 then begin 147 if Item.Index = 0 then begin 148 Item.Caption := 'IP'; 149 Item.SubItems.Add(IntToHex(Cpu.IP, 8)); 150 end else begin 151 Item.Caption := 'R' + IntToStr(Item.Index - 1); 152 Item.SubItems.Add(IntToHex(Cpu.Registers[Item.Index - 1], 8)); 153 end; 127 154 end; 128 155 end; … … 138 165 ReloadMemoryDump; 139 166 ReloadRegisterDump; 167 LabelTicks.Caption := 'Ticks: ' + IntToStr(Cpu.Ticks); 140 168 end; 141 169
Note:
See TracChangeset
for help on using the changeset viewer.