Changeset 31 for branches/UltimatOS
- Timestamp:
- Jul 6, 2022, 1:05:27 AM (2 years ago)
- Location:
- branches/UltimatOS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UltimatOS/Graphics.asm
r30 r31 1 ColorText: .dd $ffffff 2 ColorBackground: .dd 0 3 1 4 Rectangle: ; R0 - Color, R1 - X, R2 - Y, R3 - Width, R4 - Height 2 5 PUSH R5 ; loop X … … 17 20 COPY R5, R3 18 21 Line: 19 OUT ScreenWriteData, R722 OUT (ScreenWriteData), R7 20 23 DEC R5 21 24 JPNZ R5, Line … … 34 37 SetPixelAddr: ; R0 - X, R1 - Y 35 38 PUSH R2 36 IN R2, ScreenGetWidth39 IN R2, (ScreenGetWidth) 37 40 SHL R2, 2 ; multiply by 4 38 SHL R0, 2 41 SHL R0, 2 ; multiply by 4 39 42 MUL R1, R2 40 43 ADD R0, R1 41 OUT ScreenSetAddr, R044 OUT (ScreenSetAddr), R0 42 45 POP R2 43 46 RET … … 57 60 PUSH R11 ; Background color 58 61 PUSH R12 ; temp value 59 PUSH R13 ; bit mask60 62 COPY R5, R1 61 63 COPY R6, R2 … … 63 65 SHL R0, 3 64 66 ADD R3, R0 65 IN R8, ScreenGetWidth67 IN R8, (ScreenGetWidth) 66 68 SET R4, CharHeight 67 SET R10, $ffffff 68 SET R11, 5 69 SET R13, 1 69 LDI R10, (ColorText) 70 LDI R11, (ColorBackground) 70 71 WriteCharLoopY: 71 72 COPY R0, R5 … … 76 77 WriteCharLoopX: 77 78 COPY R12, R7 78 AND R12, R1379 ANDI R12, 1 79 80 JPZ R12, WriteCharNext 80 OUT ScreenWriteData, R1081 OUT (ScreenWriteData), R10 81 82 JP WriteCharNext2 82 83 WriteCharNext: 83 OUT ScreenWriteData, R1184 OUT (ScreenWriteData), R11 84 85 WriteCharNext2: 85 86 DEC R9 … … 90 91 INC R3 91 92 JPNZ R4, WriteCharLoopY 92 POP R1393 93 POP R12 94 94 POP R11 … … 106 106 PUSH R3 ; loop variable 107 107 PUSH R4 ; character width 108 PUSH R5 ; byte mask109 108 PUSH R6 ; X 110 109 PUSH R7 ; Y … … 115 114 COPY R7, R2 116 115 COPY R3, R0 117 SET R5, $ff118 116 SET R4, CharWidth 119 117 TextOutLoop: 120 118 LD R0, (R3) 121 AND R0, R5119 ANDI R0, $ff 122 120 JPZ R0, TextOutLoop2 123 121 COPY R1, R6 … … 133 131 POP R7 134 132 POP R6 135 POP R5136 133 POP R4 137 134 POP R3 -
branches/UltimatOS/UCpu.pas
r30 r31 9 9 TInstruction = (inNop, inHalt, inSet, inInput, inOutput, inInc, inDec, inJp, 10 10 inJpz, inJpnz, inAdd, inSub, inCall, inRet, inPush, inPop, inCopy, 11 inShl, inShr, inLoad, in Store, inMul, inAnd, inOr, inXor);11 inShl, inShr, inLoad, inLoadi, inStore, inMul, inAnd, inAndi, inOr, inXor); 12 12 TAddress = Integer; 13 13 PAddress = ^TAddress; … … 107 107 R[RegIndex] := PData(@Memory.Data[R[RegIndex2]])^; 108 108 end; 109 inLoadi: begin 110 RegIndex := ReadByte; 111 Address := ReadAddress; 112 R[RegIndex] := PData(@Memory.Data[Address])^; 113 end; 109 114 inStore: begin 110 115 RegIndex := ReadByte; … … 194 199 RegIndex2 := ReadByte; 195 200 R[RegIndex] := R[RegIndex] and R[RegIndex2]; 201 end; 202 inAndi: begin 203 RegIndex := ReadByte; 204 R[RegIndex] := R[RegIndex] and ReadData; 196 205 end; 197 206 inOr: begin -
branches/UltimatOS/UInstructionWriter.pas
r29 r31 8 8 type 9 9 TInstructionParam = (ipNone, ipRegIndex, ipAddress, ipData, ipIndex, 10 ipRegIndexRel );10 ipRegIndexRel, ipAddressRel); 11 11 12 12 TInstructionDef = class … … 72 72 procedure WriteReg(Index: Byte); 73 73 procedure WriteByte(Value: Byte); 74 procedure WriteWord(Value: Word); 75 procedure WriteCardinal(Value: Cardinal); 74 76 constructor Create; 75 77 destructor Destroy; override; … … 190 192 end; 191 193 end; 194 end; 195 ipAddressRel: begin 196 Address := Trim(ParseText(Text, ',')); 197 if Address.StartsWith('(') and Address.EndsWith(')') then begin 198 Address := Copy(Address, 2, Length(Address) - 2); 199 if TryStrToInt(Address, Value) then begin 200 WriteAddress(Value); 201 end else begin 202 FoundConstant := Constants.SearchByName(UpperCase(Address)); 203 if Assigned(FoundConstant) then begin 204 WriteAddress(FoundConstant.Value); 205 Exit; 206 end; 207 FoundLabel := Labels.SearchByName(UpperCase(Address)); 208 if Assigned(FoundLabel) then begin 209 // Existing label 210 WriteAddress(FoundLabel.Address); 211 end else begin 212 // Forward label reference 213 with Labels.AddNew(UpperCase(Address), -1) do begin 214 SetLength(ForwardRefs, Length(ForwardRefs) + 1); 215 ForwardRefs[Length(ForwardRefs) - 1] := IP; 216 end; 217 WriteAddress(0); 218 end; 219 end; 220 end else Error('Expected indirect address ' + Address); 192 221 end; 193 222 ipRegIndex: begin … … 333 362 end else WriteByte(StrToInt(Param)); 334 363 end; 364 end else 365 if InstructionName = 'dw' then begin 366 while Text <> '' do begin 367 Param := ParseText(Text, ','); 368 if Param.StartsWith('"') and Param.EndsWith('"') then begin 369 Param := Copy(Param, 2, Length(Param) - 2); 370 for I := 1 to Length(Param) do 371 WriteWord(Ord(Param[I])); 372 end else WriteWord(StrToInt(Param)); 373 end; 374 end else 375 if InstructionName = 'dd' then begin 376 while Text <> '' do begin 377 Param := ParseText(Text, ','); 378 if Param.StartsWith('"') and Param.EndsWith('"') then begin 379 Param := Copy(Param, 2, Length(Param) - 2); 380 for I := 1 to Length(Param) do 381 WriteCardinal(Ord(Param[I])); 382 end else WriteCardinal(StrToInt(Param)); 383 end; 335 384 end else Error('Unsupported directive name ' + InstructionName); 336 385 end else begin … … 383 432 end; 384 433 434 procedure TInstructionWriter.WriteWord(Value: Word); 435 begin 436 PWord(@Memory.Data[IP])^ := Value; 437 Inc(IP, SizeOf(Word)); 438 end; 439 440 procedure TInstructionWriter.WriteCardinal(Value: Cardinal); 441 begin 442 PCardinal(@Memory.Data[IP])^ := Value; 443 Inc(IP, SizeOf(Cardinal)); 444 end; 445 385 446 constructor TInstructionWriter.Create; 386 447 begin … … 392 453 AddNew(inHalt, 'HALT'); 393 454 AddNew(inSet, 'SET', ipRegIndex, ipData); 394 AddNew(inInput, 'IN', ipRegIndex, ipAddress );395 AddNew(inOutput, 'OUT', ipAddress , ipRegIndex);455 AddNew(inInput, 'IN', ipRegIndex, ipAddressRel); 456 AddNew(inOutput, 'OUT', ipAddressRel, ipRegIndex); 396 457 AddNew(inInc, 'INC', ipRegIndex); 397 458 AddNew(inDec, 'DEC', ipRegIndex); … … 409 470 AddNew(inShr, 'SHR', ipRegIndex, ipIndex); 410 471 AddNew(inLoad, 'LD', ipRegIndex, ipRegIndexRel); 472 AddNew(inLoadi, 'LDI', ipRegIndex, ipAddressRel); 411 473 AddNew(inStore, 'ST', ipRegIndexRel, ipRegIndex); 412 474 AddNew(inMul, 'MUL', ipRegIndex, ipRegIndex); 413 475 AddNew(inAnd, 'AND', ipRegIndex, ipRegIndex); 476 AddNew(inAndi, 'ANDI', ipRegIndex, ipData); 414 477 AddNew(inOr, 'OR', ipRegIndex, ipRegIndex); 415 478 AddNew(inXor, 'XOR', ipRegIndex, ipRegIndex); -
branches/UltimatOS/UMachine.pas
r30 r31 27 27 function GetSize: TPoint; 28 28 procedure SetSize(AValue: TPoint); 29 procedure Reset; override;30 29 public 31 30 Memory: TMemory; 32 31 PendingRefresh: Boolean; 32 procedure Reset; override; 33 33 procedure SetPointer(Value: Integer); 34 34 procedure WriteData(Value: Integer); … … 81 81 implementation 82 82 83 uses84 UInstructionWriter;85 86 83 { TDevice } 87 84
Note:
See TracChangeset
for help on using the changeset viewer.