Changeset 179
- Timestamp:
- Apr 12, 2019, 3:23:47 PM (6 years ago)
- Location:
- branches/virtualcpu4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/UFormMain.pas
r178 r179 187 187 R3: Byte; 188 188 R4: Byte; 189 LabelStart: Integer;190 189 LabelText: Integer; 190 LabelText2: Integer; 191 191 LabelPrint: Integer; 192 192 LabelClearScreen: Integer; 193 LabelPrintLoop: Integer; 194 LabelConsole: Integer; 195 LabelMain: Integer; 193 196 begin 194 197 R1 := 1; … … 198 201 with InstructionWriter do begin 199 202 Init; 200 // Print Hello world text 201 LabelText := 200; 202 Loadi(R1, LabelText); 203 Loadi(R2, 12); 203 LabelMain := $100; 204 Jump(LabelMain); 205 206 LabelText := IP; 207 WriteString('Hello World!'); 208 209 LabelText2 := IP; 210 WriteString('Good day!'); 211 204 212 LabelPrint := IP; 213 Push(R3); 214 Push(R2); 215 Push(R1); 216 LabelPrintLoop := IP; 205 217 DataPrefix8; LoadMem(R3, R1); 206 218 DataPrefix8; Output(0, R3); … … 208 220 Decrement(R2); 209 221 Test(R2); 210 JumpNotZero(LabelPrint); 222 AddrPrefix8; JumpNotZero(LabelPrintLoop); 223 Pop(R1); 224 Pop(R2); 225 Pop(R3); 226 Return; 227 228 IP := LabelMain; 229 230 // Print Hello world text 231 Loadi(R1, LabelText); 232 Loadi(R2, 12); 233 Call(LabelPrint); 234 Loadi(R1, LabelText2); 235 Loadi(R2, 9); 236 Call(LabelPrint); 211 237 212 238 // Draw to video memory … … 231 257 // Read keyboard and print to console 232 258 Loadi(R1, 100); 233 Label Start:= IP;259 LabelConsole := IP; 234 260 Increment(R1); 235 261 Loadi(R2, $100); … … 237 263 DataPrefix8; Input(R2, 0); 238 264 DataPrefix8; Output(0, R2); 239 Jump(LabelStart); 265 Jump(LabelConsole); 266 240 267 Halt; 241 IP := LabelText;242 WriteString('Hello World!');243 268 end; 244 269 end; -
branches/virtualcpu4/UInstructionWriter.pas
r178 r179 47 47 procedure Push(Reg: TRegIndex); 48 48 procedure Pop(Reg: TRegIndex); 49 procedure Call(Addr: QWord); 50 procedure Return; 49 51 procedure DataPrefix8; 50 52 procedure DataPrefix16; … … 205 207 end; 206 208 209 procedure TInstructionWriter.Call(Addr: QWord); 210 begin 211 PrefixBegin; 212 Write8(Byte(opCall)); 213 WriteAddress(Addr); 214 PrefixEnd; 215 end; 216 217 procedure TInstructionWriter.Return; 218 begin 219 PrefixBegin; 220 Write8(Byte(opRet)); 221 PrefixEnd; 222 end; 223 207 224 procedure TInstructionWriter.DataPrefix8; 208 225 begin -
branches/virtualcpu4/UMachine.pas
r177 r179 54 54 Screen := TScreen.Create; 55 55 Screen.Size := Point(320, 240); 56 Screen.MemoryBase := $ 100;56 Screen.MemoryBase := $200; 57 57 MemorySize := $1000000; 58 58 Cpu.Memory := Memory;
Note:
See TracChangeset
for help on using the changeset viewer.