Changeset 2
- Timestamp:
- Nov 6, 2009, 10:24:38 AM (15 years ago)
- Location:
- branches/Z80
- Files:
-
- 7 added
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Z80
-
Property svn:ignore
set to
backup
Compiler.exe
lib
-
Property svn:ignore
set to
-
branches/Z80/Compiler.dpr
r1 r2 6 6 {R-} 7 7 { $M 16384,0,655360 } 8 9 uses10 UZ80Compiler in 'UZ80Compiler.pas';11 8 12 9 CONST … … 455 452 done := FALSE; 456 453 WHILE (Length(line)>0) AND NOT done DO BEGIN 457 454 word := word + Upcase(line[1]); 458 455 Delete(line,1,1); 459 456 IF Length(line)>0 THEN 460 457 done := Pos(Upcase(line[1]),AlphaNumeric)=0; 461 458 END; -
branches/Z80/UZ80Compiler.pas
r1 r2 1 1 unit UZ80Compiler; 2 3 {$mode Delphi}{$H+} 2 4 3 5 interface 4 6 7 uses 8 Classes, SysUtils, UDynamicNumber; 9 10 type 11 TMaskedValue = class 12 private 13 function GetSize: Integer; 14 procedure SetSize(const AValue: Integer); 15 public 16 Value: TDynamicNumber; 17 Mask: TDynamicNumber; 18 property Size: Integer read GetSize write SetSize; 19 end; 20 21 TStringEnumeration = class 22 Values: TStringList; 23 constructor Create; 24 destructor Destroy; override; 25 end; 26 27 TOperandType = (otEnumeration, otConstant); 28 29 TOperand = class 30 OperandType: TOperandType; 31 MaskedValue: TMaskedValue; 32 Enumeration: TStringEnumeration; 33 constructor Create; 34 destructor Destroy; override; 35 end; 36 37 TOpcode = class 38 Name: string; 39 Cycles: Integer; 40 Operands: TList; 41 MaskedValue: TMaskedValue; 42 constructor Create; 43 destructor Destroy; override; 44 end; 45 46 TZ80Compiler = class 47 private 48 OperandEnumerations: TList; 49 Opcodes: TList; 50 MachineCode: TMemoryStream; 51 procedure InitOpcodes; 52 public 53 procedure Load(StringList: TStringList); 54 constructor Create; 55 destructor Destroy; override; 56 end; 57 5 58 implementation 6 59 60 { TZ80Compiler } 61 62 procedure TZ80Compiler.InitOpcodes; 63 var 64 SigleRegistersEnum: TStringEnumeration; 65 begin 66 SigleRegistersEnum := TStringEnumeration.Create; 67 with SigleRegistersEnum do begin 68 Values.Add('B'); 69 Values.Add('C'); 70 Values.Add('D'); 71 Values.Add('E'); 72 Values.Add('H'); 73 Values.Add('L'); 74 Values.Add('(HL)'); 75 Values.Add('A'); 76 end; 77 OperandEnumerations.Add(SigleRegistersEnum); 78 79 with TOpcode(Opcodes[Opcodes.Add(TOpcode.Create)]) do begin 80 Name := 'NOP'; 81 with MaskedValue do begin 82 Value.Assign(0); 83 Mask.Assign($ff); 84 end; 85 end; 86 with TOpcode(Opcodes[Opcodes.Add(TOpcode.Create)]) do begin 87 Name := 'INC'; 88 with MaskedValue do begin 89 Value.Assign($04); 90 Mask.Assign($c7); 91 end; 92 with TOperand(Operands[Operands.Add(TOperand.Create)]) do begin 93 OperandType := otEnumeration; 94 Enumeration := SigleRegistersEnum; 95 with MaskedValue do begin 96 Value.Assign($00); 97 Mask.Assign($38); 98 end; 99 end; 100 end; 101 end; 102 103 procedure TZ80Compiler.Load(StringList: TStringList); 104 var 105 I: Integer; 106 begin 107 for I := 0 to StringList.Count - 1 do begin 108 109 end; 110 end; 111 112 constructor TZ80Compiler.Create; 113 begin 114 MachineCode := TMemoryStream.Create; 115 Opcodes := TList.Create; 116 OperandEnumerations := TList.Create; 117 InitOpcodes; 118 end; 119 120 destructor TZ80Compiler.Destroy; 121 var 122 I: Integer; 123 begin 124 for I := 0 to Opcodes.Count - 1 do 125 TOpcode(Opcodes[I]).Destroy; 126 Opcodes.Destroy; 127 for I := 0 to OperandEnumerations.Count - 1 do 128 TStringEnumeration(OperandEnumerations[I]).Destroy; 129 OperandEnumerations.Destroy; 130 MachineCode.Destroy; 131 inherited Destroy; 132 end; 133 134 { TMaskedValue } 135 136 function TMaskedValue.GetSize: Integer; 137 begin 138 Result := Value.Size; 139 end; 140 141 procedure TMaskedValue.SetSize(const AValue: Integer); 142 begin 143 Value.Size := AValue; 144 Mask.Size := AValue; 145 end; 146 147 { TOpcode } 148 149 constructor TOpcode.Create; 150 begin 151 MaskedValue := TMaskedValue.Create; 152 end; 153 154 destructor TOpcode.Destroy; 155 var 156 I: Integer; 157 begin 158 for I := 0 to Operands.Count - 1 do 159 TOperand(Operands[I]).Destroy; 160 Operands.Destroy; 161 MaskedValue.Destroy; 162 inherited Destroy; 163 end; 164 165 { TOperand } 166 167 constructor TOperand.Create; 168 begin 169 MaskedValue := TMaskedValue.Create; 170 Enumeration := nil; 171 end; 172 173 destructor TOperand.Destroy; 174 begin 175 MaskedValue.Destroy; 176 inherited Destroy; 177 end; 178 179 { TStringEnumeration } 180 181 constructor TStringEnumeration.Create; 182 begin 183 Values := TStringList.Create; 184 end; 185 186 destructor TStringEnumeration.Destroy; 187 begin 188 Values.Destroy; 189 inherited Destroy; 190 end; 191 7 192 end.
Note:
See TracChangeset
for help on using the changeset viewer.