List of menmonic with arguments and explanation ----------------------------------------------- 1) Name of menmonic (given in alphabetical order) 2) Syntax of mnemonic in mudasm file, followed by memory usage in byteform Syntax consists of mnemonic and parameters, where word, int and float are straightforward, string is text of any length (including newlines) delimited with ~, local is name of local/argument starting with '@', conditions are concatenated letters ( 'e' - equal, 'g' - greated that, 'l' - lesser than ). 3) Stack status - 4) Description 5) On what types of items can instruction be used --- aadd aadd [u8/p24] V2,v1 -> V2 Pops item from stack and add it to end of array v2. Array will be enlarged if needed. Array pointer stays on stack (should it?) Can be used only with array + item of type compatible to given array. --- abort abort [u8/p24] (do not use stack) Aborts VM with error code. Used internally to catch errors. Not for normal use. --- add add [u8/p24] v2,v1 -> v3 Adds together two values from stack and put sum on stack. Can be used with ints or floats, but both items must be same type. --- alen alen [u8/p24] V1 -> V1,v2 Returns length of array. Array stays on stack(should it?) and is under length. Can be used only with arrays. --- apop apop [u8/p24] V3,v2,v1 -> V3 Pops value from stack into array at given index ( V3[v2] = v1; ). Array stays on stack(should it?). Can be used with {array, int, object; conforming to array type } --- apush apush [u8/p24] V2,v1 -> V2,v3 Pushes value from array at given index to stack. Array stays on stack(should it?). Can be used with {array, int} --- call call (word name_of_fun) ILLEGAL INSIDE VM Pseudo opcode for excuting calls of type unknown at compile time. At load time will be converted into fcall or icall (see). --- cast2f cast2f [u8/p24] v1 -> v2 Casts int value to float. Can be used only with int. --- cast2i cast2i [u8/p24] v1 -> v2 Casts float value to int. Can be used only with float. --- checkcast checkcast (word class_name) [u8/p8/u16] v1 -> v2 Checks if object on stack can be cast to class given in operand (class_name). Puts integer 1(true)/0(false) on stack. Null pointers can always be cast. Can be used only with objects. --- clone clone [u8/p24] V1 -> V1, V1 Clones any object at stack, take care of all needed registrations. Can be used with any item. --- dec dec [u8/p24] v1 -> v1 Decreases value on stack by 1. Can be used with int or float. --- decl decl (local local_id) [u8/p8/u16] (do not use stack) Decreases value of local variable by 1. Can be used with int or float. --- div div [u8/p24] v2,v1 -> v1 Divides v2 by v1 and put result on stack. Can be used with ints or floats, but both items must be same type. --- exit exit (u8 exit_value) [u8/u8/p16] (do not use stack) Ends VM execution and sets exitCode to exit_value. Should not be used normally. --- fcall fcall (word name_of_fun) [u8/p8/u16] (do not use stack) Calls function written in mudasm. Leaves trace so later ret will return to following instruction. --- fcmp fcmp (conditions cond) (word label) [u8/u8/u16] v1,v2 -> _ If v1 and v2 (v1 - v2) fulfills given condition, jump to label. If not continue. Both values are popped from stack. Can be used only for floats. --- feval feval (conditions cond) (word label) [u8/u8/u16] v1 -> _ If v1 compared to zero fulfills given condition jump to label. If not continue. Value is popped from stack. Can be used only for float. --- getfield getfield (word class) (word field) [u8/p8/u16] v1 -> v2 Pops object from stack and pushes field of it to stack. Field is determined at load time by looking up clazz and field name and saved internally us number. Compiler has to assure that this opcode will be used only for objects of given class, or class descending from it (to be exact, or class being parent of class given as far as it have defined given field). Can be use only for objects. --- icall icall (word name_of_fun) [u8/p8/u16] (do not use stack) Leaves trace,calls interface function written in C and then collect trace. It is possible that interface fun will modify trace stack actually allowing to return to other point, or call some mudasm fun. --- icmp icmp (conditions cond) (word label) [u8/u8/u16] v1,v2 -> _ If v1 and v2 (v1 - v2) fulfills given condition, jump to label. If not continue. Both values are popped from stack. Can be used only for ints. --- ieval ieval (condition cond) (word label) [u8/p8/u16] v1 -> _ If v1 compared to zero fulfills given condition jump to label. If not continue. Value is popped from stack. Can be used only for int. --- ilookupswitch ilookupswitch (u8 count) (word default_label) [u8/u8/u16] (int case1) (word case1_label) [s32] [p16/u16] .... v1 -> _ Compares value from stack with each given case. If it is the same, jumps to corresponding label. If not ( gone trough 'count' cases ) jumps to 'default_label'. Max 255 cases. Can be used only with ints. --- inc inc [u8/p24] v1 -> v2 Increases value on stack by 1. Can be used with int or float. --- incl incl (local local_id) [u8/p8/u16] (do not use stack) Increases value of local variable by 1. Can be used with int or float. --- initl initl (local number) [u8/p8/u16] (do not use stack) Allocates space for 'number' of additional local variables and fill them with nulls. --- initp initp (u16 n ) [u8/p8/u16] vn, vn-1, .., v2, v1 -> _ Allocates space for 'n' local variables and fill them with items from stack. Top of stack will be local 0, next one local 1 and so on. Should be used to initlialize arguments at start of function. (same as: initl n; popl 0; popl 1; ..;popl n-2; popl n-1; ) Can be used with any types of items. --- isnull isnull (condition cond) (word label) [u8/p24] v1 -> _ Compares object on the stack to null. If result conforms to condition jump to label. If not continue. Can be used only with VMObject. --- itableswitch itableswitch (word default_label) (int min) (int max) [u8/p8/u16] [s32] [s32] (int case1) (word case1_label) [s32] [p16/u16] ... v1 -> _ Does a quick table lookup for int on stack and jumps to corresponding label. If value is outside limits given in table jumps to 'default_label'. Not every case between min and max must be given explicite - missing ones will be filled with default jumps. Only really needed one is max - it indicates last entry in table. Can be used only for int. --- jmp jmp (word label) [u8/p8/u16] (do not use stack) Unconditionally jumps to given label. --- licmp licmp (local loc) (condition cond) (word label) [u8/u8/u16] [p16/u16] v1 -> _ Compares value contained in given local to value from stack and jumps to label if they are in relation confoming to 'cond'. ( locals[loc] - v1 ) If not continue. Both values must be ints. --- lieval licmp (local loc) (condition cond) (word label) [u8/u8/u16] [p16/u16] (do not use stack) Compares value contained in given local with zero and jumps to label if they are in relation confoming to 'cond'. If not continue. Both values must be ints. --- mod mod [u8/p24] v2,v1 -> v3 Put v2 modulo v1 on stack. Can be used only with ints. --- movc movc ((local loc) (constant c) ) [u8/p8/u16] [s32] (do not use stack) Puts constant into local variable. Same as: pushc c; popl loc; --- movf movf ((local loc) (float f)) [u8/p8/u16] [float] (do not use stack) Put float value in given local variable. Same as: pushf f; popl loc; --- movi movi ((local loc) (int i)) [u8/p8/u16] [int] (do not use stack) Put int value in given local variable. Same as: pushi i; popl loc; --- mpop mpop (u8 number) [u8/u8/p16] vn, vn-1, .., v2, v1 -> _ Pops 'number' of items from stack. (same as: pop; pop; pop; ...; pop; n times) Can be used with any types of items. --- mul mul [u8/p24] v2,v1 -> v3 Multipy v2 and v1 and puts result on stack. Can be used with ints or floats, but both items must be same type. --- nop nop [u8/p24] (do not use stack) Do nothing. --- ocmp ocmp [u8/p24] v2,v1 -> _ Compares two VMObject pointers and pops both. If result comply to condition jump to label. If not continue. Can be used only with VMObjects. --- pop pop [u8/p24] v1 -> _ Pops one item from stack. Can be used with any type of item. --- popl popl (local nlocal) [/u8/p8/u16] v1 -> _ Pops item from stack and puts it into local variable 'nlocal'. Takes care of dereferencing previous item. Can be used with any type of item. --- popstat popstat (word staticname) [u8/p8/u16] v1 -> _ Pops value from stack and puts it into static slot. Takes care of needed referencing/dereferencing. Can be used for any type of object. --- pushc pushc ((constype type) (something val)) [u8/p8/u16] _ -> v1 Pushes constant on stack. Most common use is pushing strings. (ie. pushc string Hello world~ ) --- pushf pushf (float val) [u8/p24, float] _ -> v1 Pushes float value to stack. --- pushfz pushfz [u8/p24] _ -> v1 Pushes float zero to stack. (same as: pushf 0;) --- pushi pushi (int val) [u8/p24, s32] _ -> v1 Pushes int value to stack. --- pushiz pushiz [u8/p24] _ -> v1 Pushes int zero to stack. (same as: pushi 0;) --- pushl pushl (local localn) [u8/p8/u16] _ -> v1 Pushes local 'localn' to stack. Takes care of cloning refrence to item. Can be used with any type of item. --- pushstat pushstat (word staticname) [u8/p8/u16] _ -> v1 Pushes value from static slot to stack. Can bes used for any type of item. --- pushthis pushthis [u8/p24] _ -> v1 Pushes 'this' pointer to stack. For now it stands for pushl 0; but in future it may change. --- ret ret [u8/p24] (do not use stack) Collects trace, returning to previous function. Dereferences local variables automatically. --- scharat scharat [u8/p24] v1, v2 -> v3 Returns character in the v1 string at position v2. Can be used only for pair string/int. --- scharatl scharatl (local loc) [u8/p8/u16] v1 -> v2 Returns character in the string indicated by local at position v1. Can be used only for pair string(local)/int(stack). --- scmp scmp (condition cond) (word label) [u8/u8/u16] v1,v2 -> _ Compares two strings and pops both. Case sensitive. If they are in relation specified by 'cond' jumps to label. If not continue. Can be used only with strings. --- sconcat sconcat [u8/p24] v1,v2 -> v3 Concatenates two strings and push resulting string on stack. Can be used only with strings. --- setfield setfield (word class) (word field) [u8/p8/u16] v1, v2 -> _ Sets field of object v1 to value v2. Field is determined at load time by looking up clazz and field name and saved internally us number. Compiler has to assure that this opcode will be used only for objects of given class, or class descending from it (to be exact, or class being parent of class given as far as it have defined given field). Can be use only for object and correct field type. --- sfloatcat sfloatcat [u8/p24] v1,v2 -> v3 Concatenates float and string. Can be used only with pair (string, float ). --- sgetarg sgetarg [u8/p24] _ -> v1 Get next argument from current_args string. --- sgetargrest sgetargrest [u8/p24] _ -> v1 Get all the rest of current_args string. --- sintcat sintcat [u8/p24] v1,v2 -> v3 Concatenates int and string. Can be used only with pair (string,int ). --- sisempty sisempty (condition cond) (word label) [u8/u8/u16] v1 -> _ Checks if string on stack is empty (""). If result conforms to 'cond' jumps to label. If not continue. (similar as: spushempty; scmp;) Can be used only with string. --- sisnumber sisnumber (condition cond) (word label) [u8/u8/p16] v1 -> v1 Checks if string can be converted to int. If result conforms to 'cond' jumps to label. If not continue. Can be used only with string. --- sleep sleep [u8/p24] v1 -> _ Suspends VM execution for value seconds. Value is given by float, but exact resolution of sleep can vary (VM will not sleep for shorter period of time, but can sleep for somewhat longer). For now resolution is set to 1 second, but this can change. Can be used only with floats. --- slookupswitch slookupswitch (u8 count) (word default_label) [u8/u8/u16] (string case1) (word case1_label) [p16/u16] [p16/u16] ... v1 -> _ Compares string at stack with every case. If match occurs jumps to corresponding label. If not jumps to 'default_label'. Max 255 cases. Can be used only for string. --- sstartargs sstartargs [u8/p24] v1 -> _ Initializes string from stack to be current_args.(later use sgetarg/sgetargrest) Can be used only with string. --- stoint stoint [u8/p24] v1 -> v2 Converts string to int. Can be used only with string. --- spushempty spushempty [u8/p24] _ -> v1 Push empty string to stack (""). --- sub sub [u8/p24] v2,v1 -> v3 Substract v1 from v2 and put result to stack. Can be used with ints or floats, but both items must be same type. --- swap swap [u8/p24] V2,V1 -> V1,V2 Swaps v1 with v2. Can be used for any types of item. --- upcast upcast (word classname) [u8/p8/u16] v1 -> v2 Changes type of v1 to 'classname'. If it is illegal (see checkcast) VM will report error. Null pointer is always upcasted without error. Can be used only for objects.