# Turbo51 System Functions

## Pascal Compiler for 8051 Microcontrollers

## Abs

Abs returns the absolute value of a variable. The result of the function has the same type as its argument, which can be Integer or Real.

## Addr

Addr returns a pointer to its argument, which can be any type including procedure or function. If argument is in DATA segment the result is of type ShortPtr, If argument is in XDATA segment the result is of type Pointer and if argument is in CODE segment (typed constant, function, procedure, static method) the result is of type CodePointer. The returned pointer isn't typed. Similar result can be obtained by the @ operator which returns a typed pointer.

## ArcTan

Arctan returns the Arctangent of X. The resulting angle is in radians.

## Assigned

Assigned returns True if P is non-nil and retuns False otherwise. P can be any pointer or procedural variable.

## Bcd

Bcd returns binary coded decimal representation of D.

## Chr

Chr returns the character which has ASCII value X.

## Concat

Concat concatenates the strings S1, S2 etc. to one long string. The resulting string is truncated at a length of 255 bytes. The same operation can be performed with the + operation. Function Concat needs XDATA memory.

## Copy

Copy returns a string which is a copy if the Count characters in S, starting at position Index. If Count is larger than the length of the string S, the result is truncated. If Index is larger than the length of the string S, then an empty string is returned. Function Copy needs XDATA memory.

## Cos

Cos returns the cosine of X, where X is an angle in radians.

## Exp

Exp returns the exponent of X, i.e. the number e to the power X.

## Frac

Frac returns the fractional part of a floating point number in X.

## Hi

Hi returns the high byte of word or pointer in X.

## High

The return value of High depends on it's argument: 1. If the argument is an ordinal type, High returns the highest value in the range of the given ordinal type. 2. If the argument is an array type or an array type variable then High returns the highest possible value of it's index. 3. If the argument is an open array identifier in a function or procedure, then High returns the highest index of the array, as if the array has a zero-based index. The return type is always the same type as the type of the argument (or type of index in arrays).

## Int

Int returns the integer part of a floating point number in X. The result is Real, i.e. a floating point number.

## Length

Length returns the length of the string S. If the strings S is empty, 0 is returned. Note: The length of the string S is stored in S [0].

## Ln

Ln returns the natural logarithm of the Real parameter X. X must be positive.

## Lo

Lo returns the low byte of word or pointer in X.

## Low

The return value of Low depends on it's argument: 1. If the argument is an ordinal type, Low returns the lowest value in the range of the given ordinal type. 2. If the argument is an array type or an array type variable then Low returns the lowest possible value of it's index. 3. If the argument is an open array identifier in a function or procedure, then Low returns the lowest index of the array which is 0. The return type is always the same type as the type of the argument (or type of index in arrays).

## MaxAvail

MaxAvail returns the size in bytes of the biggest free memory block in the heap.

## MemAvail

MemAvail returns the size in bytes of all free memory in the heap.

## New

New returns address of allocated memory for a new instance of the type PType. If PType is a pointer to a object type, then it is possible to specify the name of the constructor with which the instance will be created.

## Odd

Odd returns True if X is odd, or False otherwise.

## Ofs

Ofs returns offset of Field in record type TRecord.

## Ord

Ord returns the ordinal value of a ordinal-type variable X.

## Pi

Pi returns the value of Pi (3.1415926535897932385).

## Pos

Pos returns the index of Substr in Str, if Str contains Substr. In case Substr isn't found, 0 is returned. The search is case-sensitive.

## Pred

Pred returns the element that precedes the element that was passed to it.

## Random

Random returns a random number larger or equal to 0 and strictly less than L. If the argument L is omitted, a Real number between 0 and 1 is returned. (0 included, 1 excluded).

## Round

Round rounds X to the closest integer, which may be bigger or smaller than X.

## Sin

Sin returns the sine of its argument X, where X is an angle in radians.

## SizeOf

SizeOf returns the size in bytes of any variable, type or record field.

## Sqr

Sqr returns the square of its argument X.

## Sqrt

Sqrt returns the square root of its argument X, which must be positive.

## Succ

Succ returns the element that succeeds the element that was passed to it.

## Swap

Swap swaps the high and low order bytes of X.

## SwapWord

SwapWord swaps the high and low order words of X.

## Trunc

Trunc returns the integer part of X, which is always smaller than (or equal to) X in absolute value.

## TypeOf

TypeOf returns the address of the VMT of the TObjectType.

## UpCase

UpCase returns the uppercase version of its argument C.