DUO LIGHT PSEUDO C DLPC contains many features of the C language. Some parts of DLPC have been added or modified for convenience. MODIFIED FEATURES - Variable types are unsigned by default. For example, "short" implies "unsigned short". Use the keyword "signed" to make a variable signed. - The "char" variable type has been replaced with "byte". Both store 8 bits of data. - The "int" variable type now has special meaning. An "int" can refer to a "byte", "short", or "long". "int" may only be used in argument signatures. - Labels are pointers to "data", and goto statements accept pointers to data. This means you can dynamically set goto locations. - Any kind of statement may be placed outside of function declarations; there is no main function. - Function invocations pass arguments by reference. This means when an argument is modified inside of a function, the change also occurs outside of the function. - Array literals are not duplicated when assigned to a variable. Modifying a variable which contains an array literal will modify the array literal permanently. ADDITIONAL FEATURES - The "data" variable type can refer to data of any length. "data" may only be used in argument signatures. - The following functions are built into DLPC and correspond to individual bytecode instructions: void write(short len, data *src, data *dest) void fill(int data, int2 amount, data *dest) signed int2 find(int data, int2 len, data *src) void convertIntToString(int num, byte *dest) void convertSignedIntToString(signed int num, byte *dest) void convertFloatToString(float num, byte *dest) int convertStringToInt(byte *text) signed int convertStringToSignedInt(byte *text) float convertStringToFloat(byte *text) void writeString(byte *text, byte *dest) byte equalString(byte *text1, byte *text2) signed int findString(byte *pattern, byte *text) int getStringLength(byte *text) void getSubstring(byte *text, int startIndex, int endIndex, byte *dest) void concatenateString(byte *text, byte *dest)l int getSpaceDelimitedStringLength(byte *text) void getSpaceDelimitedStringElement(byte *text, int index, byte *dest) int random(int max): Maximum is exclusive. float sine(float num) void writeTime(int num) int readTime() void sleep(int num) void clearDisplay() void writeDisplay(int posX, int posY, byte *text) void readDisplay(int posX, int posY, int2 len, byte *dest)0 void convertKeyToString(short key, byte shift, byte *dest) short convertStringToKey(byte *text) byte keyIsPressed(short key) short promptKey() void promptString(int posY, byte *dest) int promptSelection(int amount, byte *text) int promptFile() void setPortMode(byte mode, byte pin) byte digitalReadPort(byte pin) void digitalWritePort(byte value, byte pin) short analogReadPort(byte pin) int getNumberOfFiles() signed long openFileByIndex(int index) signed long openFileByName(byte *text) signed long openFileAfterFile(signed long handle) signed long createFile(byte *name, int size) void readFile(signed long handle, byte *dest) void writeFile(byte *src, signed long handle) void getFileName(signed long handle, byte *dest) int getFileSize(signed long handle) void deleteFile(signed long handle) void runFile(signed long handle) void quit() byte convertStringToOpcode(byte *text) void convertByteToHex(byte num, byte *dest) byte convertHexToByte(byte *text) data *allocate(int len) void free(data *ptr) void scrollDisplay(byte direction, byte *text) int getDisplayWidth() int getDisplayHeight() void gameOfLife(int width, int height, byte *src, byte *dest) byte mandelbrot(float real, float imag, float offset, int iter) float pow(float num, float exp) float log(float num, float base) PERSISTENT FEATURES - Define statements interpreted by precompiler: #define - Single line comments: // - Variable types: void, short, long, float - Pointers and one dimensional arrays: *, [, ] - Functions - Code blocks: {, } - Labels: : - Assignment operators: =, +=, -=, *=, /=, %=, &=, |= ^=, <<=, >>= - Increment and decrement operators: ++, -- - Arithmetic operators: +, -, *, /, % - Negation operator: - - Bitwise operators: ~, &, |, ^, <<, >> - Boolean operators: !, &&, || - Comparison operators: ==, !=, <, <=, >, >= - Reference and dereference operators: &, *, [, ] - Type conversion operators: (, ) - Subexpression grouping: (, ) - Function invocation: (, ) - Decimal integer literals, decimal float literals, hexadecimal value literals - Byte array literals: {, } - Character literals: ' - String literals: " - Escape sequences in character and string literals: \ - Flow control: goto, if, else, while, break, continue, return MISSING FEATURES - Most precompiler directives - Block comments, comments on the same line as a statement - long long, double - Multidimensional arrays - Enumerations - Structs - sizeof - do, for, switch