Changeset 171 for branches/virtualcpu4/UInstructionWriter.pas
- Timestamp:
- Apr 10, 2019, 4:00:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/UInstructionWriter.pas
r170 r171 19 19 procedure Write32(Value: DWord); 20 20 procedure Write64(Value: QWord); 21 procedure WriteAddress(Value: TAddress); 22 procedure WriteData(Value: QWord); 23 procedure WriteString(Text: string); 21 24 procedure Nop; 22 25 procedure Halt; 23 26 procedure LoadConst(Reg: Byte; Value: QWord); 24 27 procedure Increment(Reg: Byte); 28 procedure Decrement(Reg: Byte); 25 29 procedure Jump(Value: QWord); 30 procedure JumpNotZero(Value: QWord); 26 31 procedure DataPrefix8; 27 32 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); 28 37 end; 29 38 … … 47 56 Write8(Byte(opLoadConst)); 48 57 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); 55 59 end; 56 60 … … 61 65 end; 62 66 67 procedure TInstructionWriter.Decrement(Reg: Byte); 68 begin 69 Write8(Byte(opDec)); 70 Write8(Reg); 71 end; 72 63 73 procedure TInstructionWriter.Jump(Value: QWord); 64 74 begin 65 75 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); 77 end; 78 79 procedure TInstructionWriter.JumpNotZero(Value: QWord); 80 begin 81 Write8(Byte(opJumpNotZero)); 82 WriteAddress(Value); 72 83 end; 73 84 … … 82 93 Write8(RegAddr); 83 94 Write8(RegSrc); 95 end; 96 97 procedure TInstructionWriter.LoadMem(RegDst, RegAddr: Byte); 98 begin 99 Write8(Byte(opLoadMem)); 100 Write8(RegDst); 101 Write8(RegAddr); 102 end; 103 104 procedure TInstructionWriter.Output(Port: TAddress; Reg: Byte); 105 begin 106 Write8(Byte(opOut)); 107 WriteAddress(Port); 108 Write8(Reg); 109 end; 110 111 procedure TInstructionWriter.Input(Reg: Byte; Port: TAddress); 112 begin 113 Write8(Byte(opIn)); 114 Write8(Reg); 115 WriteAddress(Port); 116 end; 117 118 procedure TInstructionWriter.Test(Reg: Byte); 119 begin 120 Write8(Byte(opTest)); 121 Write8(Reg); 122 end; 123 124 procedure TInstructionWriter.WriteString(Text: string); 125 var 126 I: Integer; 127 begin 128 for I := 1 to Length(Text) do 129 Write8(Ord(Text[I])); 84 130 end; 85 131 … … 108 154 end; 109 155 156 procedure TInstructionWriter.WriteAddress(Value: TAddress); 157 begin 158 case Cpu.AddressSize of 159 bw8: Write8(Value); 160 bw16: Write16(Value); 161 bw32: Write32(Value); 162 bw64: Write64(Value); 163 end; 164 end; 165 166 procedure TInstructionWriter.WriteData(Value: QWord); 167 begin 168 case Cpu.DataSize of 169 bw8: Write8(Value); 170 bw16: Write16(Value); 171 bw32: Write32(Value); 172 bw64: Write64(Value); 173 end; 174 end; 175 110 176 end. 111 177
Note:
See TracChangeset
for help on using the changeset viewer.