Changeset 218
- Timestamp:
- Oct 14, 2020, 7:51:40 PM (4 years ago)
- Location:
- branches/CpuSingleSize
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CpuSingleSize/Sample.asm
r217 r218 1 DB Start, KeyInterrupt 1 DB Start, KeyInterrupt, 'ABC', 123 2 2 NOP 3 3 NOP … … 19 19 ;SET R0, 6 20 20 LOOP2: 21 SET R0, H ELLO21 SET R0, Hello 22 22 SET R1, 12 23 CALL W RITESTR23 CALL WriteStr 24 24 25 25 ; SET R0, 0 … … 44 44 PUSH R3 45 45 LDIR_LOOP: 46 LD R3, R047 ST R1, R346 LD R3, (R0) 47 ST (R1), R3 48 48 INC R0 49 49 INC R1 … … 54 54 55 55 SETR: 56 ST R0, R256 ST (R0), R2 57 57 INC R0 58 58 DEC R1 … … 60 60 RET 61 61 62 W RITESTR:62 WriteStr: 63 63 PUSH R2 64 64 PUSH R3 65 65 SET R3, 0 66 W RITESTR_LOOP:67 LD R2, R068 OUT R3, R266 WriteStrLoop: 67 LD R2, (R0) 68 OUT (R3), R2 69 69 INC R0 70 70 DEC R1 71 JNZ R1, W RITESTR_LOOP71 JNZ R1, WriteStrLoop 72 72 POP R3 73 73 POP R2 … … 80 80 SET R0, 1 81 81 SET R1, 0 82 OUT R0, R182 OUT (R0), R1 83 83 SET R0, 3 84 IN R1, R084 IN R1, (R0) 85 85 SET R0, 4 86 IN R2, R086 IN R2, (R0) 87 87 MUL R2, R1 88 88 SET R0, 2 89 89 SET R1, 120 90 90 ClearScreenLoop: 91 OUT R0, R191 OUT (R0), R1 92 92 DEC R2 93 93 JNZ R2, ClearScreenLoop … … 97 97 RET 98 98 99 H ELLO:99 Hello: 100 100 DB 'Hello friend' 101 101 … … 105 105 PUSH R2 106 106 SET R3, 0 107 IN R2, R3108 OUT R3, R2107 IN R2, (R3) 108 OUT (R3), R2 109 109 POP R2 110 110 POP R3 -
branches/CpuSingleSize/UAssembler.pas
r217 r218 162 162 Token: TToken; 163 163 LastPos: TParserPos; 164 Number: Integer; 164 165 begin 165 166 Result := False; … … 173 174 if I > 0 then 174 175 Parser.Expect(tkSpecialSymbol, ','); 175 Token := Parser.ReadNext;176 176 if InstructionInfo.Params[I] = ptReg then begin 177 if (Token.Value <> '') and (Token.Value[1] = 'R') then 178 Token.Value := Copy(Token.Value, 2, MaxInt) 179 else Error('Expected register name.', Token.Pos); 180 Memory.Write(StrToInt(Token.Value)); 177 Token := Parser.ReadNext; 178 if (Token.Value <> '') and (Token.Value[1] = 'R') then begin 179 Token.Value := Copy(Token.Value, 2, MaxInt); 180 if TryStrToInt(Token.Value, Number) then 181 Memory.Write(Number) 182 else Error('Expected numeric register index error', Token.Pos); 183 end else Error('Expected register name starting with R character.', Token.Pos); 184 end else 185 if InstructionInfo.Params[I] = ptRegIndirect then begin 186 Parser.Expect(tkSpecialSymbol, '('); 187 Token := Parser.ReadNext; 188 if (Token.Value <> '') and (Token.Value[1] = 'R') then begin 189 Token.Value := Copy(Token.Value, 2, MaxInt); 190 if TryStrToInt(Token.Value, Number) then 191 Memory.Write(Number) 192 else Error('Expected numeric register index error', Token.Pos); 193 end else Error('Expected register name starting with R character.', Token.Pos); 194 Parser.Expect(tkSpecialSymbol, ')'); 181 195 end else 182 196 if InstructionInfo.Params[I] = ptNumber then begin 197 Token := Parser.ReadNext; 183 198 ParseNumParam(Token); 184 199 end; -
branches/CpuSingleSize/UDisassembler.pas
r216 r218 55 55 InstText := InstText + 'R' + IntToStr(Value); 56 56 end else 57 if InstructionInfo.Params[J] = ptRegIndirect then begin 58 InstText := InstText + '(R' + IntToStr(Value) + ')'; 59 end else 57 60 if InstructionInfo.Params[J] = ptNumber then begin 58 61 InstText := InstText + IntToHex(Value, 8); -
branches/CpuSingleSize/UInstructions.pas
r216 r218 9 9 10 10 type 11 TParamType = (ptNone, ptNumber, ptReg );11 TParamType = (ptNone, ptNumber, ptReg, ptRegIndirect); 12 12 TParamTypeArray = array of TParamType; 13 13 14 TInstructionInfo = class 14 15 Instruction: TInstruction; … … 77 78 AddNew(inInc, 'INC', [ptReg], 'Increments value in specified register.'); 78 79 AddNew(inDec, 'DEC', [ptReg], 'Decrements value in specified register.'); 79 AddNew(inLoad, 'LD', [ptReg, ptReg ], 'Loads value from memory to register.');80 AddNew(inStore, 'ST', [ptReg , ptReg], 'Stores value from register to memory.');80 AddNew(inLoad, 'LD', [ptReg, ptRegIndirect], 'Loads value from memory to register.'); 81 AddNew(inStore, 'ST', [ptRegIndirect, ptReg], 'Stores value from register to memory.'); 81 82 AddNew(inAdd, 'ADD', [ptReg, ptReg], 'Adds second register to first register.'); 82 83 AddNew(inSub, 'SUB', [ptReg, ptReg], 'Subtracts second register from first register.'); 83 AddNew(inIn, 'IN', [ptReg, ptReg ], 'Reads value from input port to register.');84 AddNew(inOut, 'OUT', [ptReg , ptReg], 'Writes value from register to output port.');84 AddNew(inIn, 'IN', [ptReg, ptRegIndirect], 'Reads value from input port to register.'); 85 AddNew(inOut, 'OUT', [ptRegIndirect, ptReg], 'Writes value from register to output port.'); 85 86 AddNew(inJumpZero, 'JZ', [ptReg, ptNumber], 'Jumps to given address if value of register is zero'); 86 87 AddNew(inJumpNotZero, 'JNZ', [ptReg, ptNumber], 'Jumps to given address if value of register is not zero'); -
branches/CpuSingleSize/UParser.pas
r217 r218 87 87 function TParser.IsSpecialSymbol(C: Char): Boolean; 88 88 begin 89 Result := (C = ':') or (C = ',') ;89 Result := (C = ':') or (C = ',') or (C = '(') or (C = ')'); 90 90 end; 91 91
Note:
See TracChangeset
for help on using the changeset viewer.