updated readme for new version

This commit is contained in:
hellerve
2015-06-16 10:58:26 +02:00
parent 9b55ee0f54
commit 74e9c43403
7 changed files with 92 additions and 99 deletions

View File

@@ -29,41 +29,40 @@ concise as possible.
Instruction set
---------------
Up until now, all the operations are executed on integers(hence the
I\* prefix).
Up until now, all the operations are executed on integers.
*Operations overview*:
* ENTRY - Specifies an entry point for the routine by its index.
* IADD - Adds the two items to each other that are on top of the stack
* ADD - Adds the two items to each other that are on top of the stack
and stores the result on top of the stack.
* ISUB - Subtracts the two items from each other that are on top of the
* SUB - Subtracts the two items from each other that are on top of the
stack and stores the result on top of the stack.
* IMULT - Multiplies the two items to each other that are on top of the
* MULT - Multiplies the two items to each other that are on top of the
stack and stores the result on top of the stack.
* IDIV - Performs a division operation to the two items that are on top
* DIV - Performs a division operation to the two items that are on top
of the stack and stores the result on top of the stack.
* IMOD - Performs a modulo operation to the two items that are on top
* MOD - Performs a modulo operation to the two items that are on top
of the stack and stores the result on top of the stack.
* ILT - Checks whether the item on top of the stack is greater than the
* LT - Checks whether the item on top of the stack is greater than the
item below it and stores a boolean on top of the stack.
* IEQ - Checks whether the item on top of the stack is equal to the
* EQ - Checks whether the item on top of the stack is equal to the
item below it and stores a boolean on top of the stack.
* IGT - Checks whether the item on top of the stack is smaller than the
* GT - Checks whether the item on top of the stack is smaller than the
item below it and stores a boolean on top of the stack.
* ILEQ - Checks whether the item on top of the stack is smaller than or
* LEQ - Checks whether the item on top of the stack is smaller than or
equal to the item below it and stores a boolean on top of the stack.
* IGEQ - Checks whether the item on top of the stack is greater than or
* GEQ - Checks whether the item on top of the stack is greater than or
equal to the item below it and stores a boolean on top of the stack.
* BR - Jumps to the instruction that is provided as an argument.
@@ -74,7 +73,7 @@ value on top of the stack is TRUE.
* BRF - Jumps to the instruction that is provided as an argument if the
value on top of the stack is FALSE.
* ICONST - Puts the argument provided to the operation on top of the
* CONST - Puts the argument provided to the operation on top of the
stack.
* LOAD - Loads an element from any position on the stack on top of the
@@ -101,7 +100,7 @@ top of the stack.
* FETCH - Fetches a value.
* IINC -Increments the value on top of the stack by one(equal to ++).
* INC -Increments the value on top of the stack by one(equal to ++).
* IDEC -Decrements the value on top of the stack by one(equal to --).
* DEC -Decrements the value on top of the stack by one(equal to --).

View File

@@ -6,7 +6,7 @@
* argc -> the argument counter
* argv -> the argument vector
*
* executes code in my dsl.
* executes code in my dsl/vm.
*/
int main(int argc, char** argv){
program prog;

View File

@@ -31,33 +31,33 @@ const char* opcodes[] = { "ADD",
};
/*The argument counter for the opcodes*/
int nargs[] = { 0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0
int nargs[] = { 0, /* ADD */
0, /* SUB */
0, /* MULT */
0, /* DIV */
0, /* MOD */
0, /* LT */
0, /* EQ */
0, /* GT */
1, /* BR */
1, /* BRT */
1, /* BRF */
1, /* CONST */
1, /* LOAD */
1, /* GLOAD */
1, /* STORE */
1, /* GSTORE */
0, /* PRINT */
0, /* POP */
0, /* HALT */
0, /* LEQ */
0, /* GEQ */
2, /* CALL */
0, /* RET */
0, /* IPRINT */
0, /* FETCH */
0, /* INC */
0 /* DEC */
};
instruction* setup_instructions(){

View File

@@ -69,7 +69,11 @@ typedef struct{
const char* name;
}instruction;
/*sets up the instruction struct*/
/**
* @brief setup_instructions
*
* sets up the instruction struct for the VM.
*/
instruction* setup_instructions();
#endif

View File

@@ -6,7 +6,7 @@
/**
* @brief die
* @param code -> the error code
* @param code -> the error code
* @param message -> the error message
*
* Lets the program die and emits an error message.

View File

@@ -9,13 +9,13 @@
/**
* @brief disassemble
* @param sp -> stack pointer
* @param fp -> function pointer
* @param ip -> instruction pointer
* @param sp -> stack pointer
* @param fp -> function pointer
* @param ip -> instruction pointer
* @param opcode -> current opcode
* @param ins -> instruction struct
* @param code -> opcodes
* @param stack -> stack
* @param ins -> instruction struct
* @param code -> opcodes
* @param stack -> stack
*
* prints current operations and a stack trace.
* Is invoked if DEBUG is defined.
@@ -34,16 +34,6 @@ static inline void disassemble(int sp, int fp, int ip, int opcode, instruction*
printf("\n");
}
/**
* @brief vm_execute
* @param code -> a list of opcodes
* @param ip -> the instruction pointer
* @param datasize -> the maximal standard datasize
* @param length -> the length of the program
*
* the main virtual machine loop. takes opcodes and
* metainformation and executes it.
*/
void vm_execute(int code[], int ip, int datasize, unsigned long length){
int* data = (int *) alloca((size_t)datasize * sizeof(int));
int stack[MAX_SIZE];

View File

@@ -17,10 +17,10 @@ typedef struct{
/**
* @brief vm_execute
* @param code -> instructions
* @param ip -> starting point
* @param code -> instructions
* @param ip -> starting point
* @param datasize -> maximum data size
* @param length -> length of program
* @param length -> length of program
*/
void vm_execute(int[], int, int, unsigned long);
@@ -32,9 +32,9 @@ program vm_compile(char*);
/**
* @brief str_split
* @param a_str -> the input string
* @param a_str -> the input string
* @param a_delim -> the delimiter
* @param elemc -> the counter of elements
* @param elemc -> the counter of elements
*
*/
char** str_split(char*, const char, unsigned int*);