Press enter to see results or esc to cancel.

System Functions Ptr, Addr, Ofs and Seg

These procedures process system function Ptr, Addr, Seg and Ofs.

Procedure Func_Ptr; Far;
Var TempExpression: TExpression;
begin
  ExpectTokenAndGetNext (Token_LeftParenthesis);
  TempExpression.ExpectIntegerExpression;
  TempExpression.CheckOrdinalRange (Ptr (SystemUnitSegment, Word_TypeOffset));
  ExpectTokenAndGetNext (Token_Comma);
  Expression^.ExpectIntegerExpression;
  Expression^.CheckOrdinalRange (Ptr (SystemUnitSegment, Word_TypeOffset));
  ExpectTokenAndGetNext (Token_RightParenthesis);
  With Expression^ do
    begin
      If (Location = elConstant) and (TempExpression.Location = elConstant) then Value.PtrSegment := TempExpression.Value.Word
        else begin
               CalculateExpressionsAndLoadLeftTo_rAX_AndRightTo_rDX (Expression^, TempExpression);
               Expression^.EndIntermediateCodeSubroutine;
               UsedRegisters := UsedRegisters + TempExpression.UsedRegisters;
             end;
      DataType := itLongInt;
      TypeDefPtr := Ptr (SystemUnitSegment, Pointer_TypeOffset);
    end;
end;

This procedure processes system functions Addr, Ofs and Seg.

Procedure Func_Addr_Ofs_Seg; Far;
begin
  ExpectTokenAndGetNext (Token_LeftParenthesis);
  Expression^.ExpectVariableReference;
  Expression^.CreatePointerToVariableReference;
  ExpectTokenAndGetNext (Token_RightParenthesis);
  Case FuncParameter of
    0: Expression^.TypeDefPtr := Ptr (SystemUnitSegment, Pointer_TypeOffset);
    1: begin
         Expression^.TypeDefPtr := Ptr (SystemUnitSegment, LongInt_TypeOffset);
         Expression^.ExtendInteger (itWord);
       end;
    2: begin
         Expression^.SwitchBetweenLoWordAndHiWord (2);
         Expression^.TypeDefPtr := Ptr (SystemUnitSegment, LongInt_TypeOffset);
         Expression^.ExtendInteger (itWord);
       end;
  end;
end;