Ignore:
Timestamp:
Aug 7, 2024, 12:12:42 AM (2 months ago)
Author:
chronos
Message:
  • Modified: Improved serial console handling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/Assembler.pas

    r9 r10  
    2929    function ParseOrg: Boolean;
    3030    function ParseInstruction: Boolean;
    31     function ParseInstructionParameter(ParamType: TParamType; Memory: TMemory): Boolean;
     31    function ParseInstructionParameter(ParamType: TParamType; Memory: TMemory;
     32      Offset: Integer): Boolean;
    3233    function ParseLabel: Boolean;
    3334    procedure UpdateLabelRefs;
    34     function ParseNumParam(out Number: TInt): Boolean;
     35    function ParseNumParam(Offset: Integer; out Number: TInt): Boolean;
    3536    function ParseReg(out RegIndex: TRegIndex): Boolean;
    3637    function ParseDataWidth(out Size: TIntSize): Boolean;
     
    9697end;
    9798
    98 function TAssembler.ParseNumParam(out Number: TInt): Boolean;
     99function TAssembler.ParseNumParam(Offset: Integer; out Number: TInt): Boolean;
    99100var
    100101  Token: TToken;
     
    116117      Result := True;
    117118    end else begin
    118       LabelRefs.Add(TLabelRef.Create(Token.Value, Memory.Position + 1, Parser.Pos.Pos));
     119      LabelRefs.Add(TLabelRef.Create(Token.Value, Memory.Position + 1 + Offset, Parser.Pos.Pos));
    119120      Number := 0;
    120121      Result := True;
     
    252253    Result := True;
    253254    while True do begin
    254       if ParseNumParam(Number) then begin
     255      if ParseNumParam(0, Number) then begin
    255256        Memory.WritePos(1, Number);
    256257      end else begin
     
    333334          LastMessagesCount := Messages.Count;
    334335          ParamMemory.Clear;
    335           if ParseInstructionParameter(ParamType, ParamMemory) and
     336          if ParseInstructionParameter(ParamType, ParamMemory, InstructionMemory.Position) and
    336337            (LastMessagesCount = Messages.Count) then begin
    337338            ParamOk := True;
     
    379380end;
    380381
    381 function TAssembler.ParseInstructionParameter(ParamType: TParamType; Memory: TMemory): Boolean;
     382function TAssembler.ParseInstructionParameter(ParamType: TParamType; Memory: TMemory;
     383  Offset: Integer): Boolean;
    382384var
    383385  LastPos: TParserPos;
     
    391393  case ParamType of
    392394    ptData: begin
    393       if ParseNumParam(Number) then Memory.WritePos(InstDataWidth, Number)
     395      if ParseNumParam(Offset, Number) then
     396      Memory.WritePos(InstDataWidth, Number)
    394397        else begin
    395398          Error(SExpectedNumber, Parser.Pos.Pos);
     
    398401    end;
    399402    ptAddress: begin
    400       if ParseNumParam(Number) then Memory.WritePos(InstAddressWidth, Number)
     403      if ParseNumParam(Offset, Number) then
     404      Memory.WritePos(InstAddressWidth, Number)
    401405        else begin
    402406          Error(SExpectedNumber, Parser.Pos.Pos);
     
    425429        Memory.WritePos(1, Byte(RegIndex));
    426430        if not Parser.Expect(tkSpecialSymbol, '+') then Result := False;
    427         if ParseNumParam(Number) then Memory.WritePos(InstAddressWidth, Number)
     431        if ParseNumParam(Offset, Number) then Memory.WritePos(InstAddressWidth, Number)
    428432          else begin
    429433            Error(SExpectedNumericIndex, Parser.Pos.Pos);
Note: See TracChangeset for help on using the changeset viewer.