Initial Commit
This commit is contained in:
285
rcbasic_build/vm_asm
Normal file
285
rcbasic_build/vm_asm
Normal file
@@ -0,0 +1,285 @@
|
||||
-------------------------
|
||||
|types of parameters
|
||||
-------------------------
|
||||
raw_number = starting character (0-9)
|
||||
n# = starting character n followed by # (# is a number denoting the number register to use)
|
||||
s# = starting character s followed by # (# is a number denoting the string register to use)
|
||||
u# = starting character u followed by # (# is a number denoting the user_type register to use)
|
||||
r# = starting character r followed by # (# is a number denoting the reference register to use) //references are set when obj_get or mov(34) or mov(38) is called
|
||||
!id = starting character is ! followed id (id is a number denoting the id vector position) //it can be used for any integer argument as well as id's
|
||||
@[data_address] = starting character is @ followed by the number specifying the offset in the data segment
|
||||
|
||||
----------------------------------------
|
||||
|SYSTEM AND VM OPERATION
|
||||
---------------------------------------
|
||||
|
||||
0 - end
|
||||
1 - dbg uint uint uint // arguments are (debug_function, file_index, line_number)
|
||||
|
||||
---------------------------------------
|
||||
|MOVING DATA
|
||||
----------------------------------------
|
||||
|
||||
32 - mov n# n#
|
||||
33 - mov n# raw_number
|
||||
34 - mov n# !id
|
||||
35 - mov !id n#
|
||||
|
||||
36 - mov$ s# s#
|
||||
37 - mov$ s# @[data_address]
|
||||
38 - mov$ s# !id
|
||||
39 - mov$ !id s#
|
||||
|
||||
40 - mov_r r# n#
|
||||
41 - mov_r$ r# s#
|
||||
|
||||
42 - mov_type u# u# //copy user types and arrays NOTE: This will do the same thing mov_r does by setting the reference pointed to by the first arg
|
||||
|
||||
--------------------------------------
|
||||
|OPERATORS
|
||||
-------------------------------------
|
||||
|
||||
43 - add$ s# s#
|
||||
|
||||
44 - add n# n#
|
||||
45 - sub n# n#
|
||||
46 - mul n# n#
|
||||
47 - div n# n#
|
||||
48 - pow n# n#
|
||||
49 - mod n# n#
|
||||
50 - shl n# n#
|
||||
51 - shr n# n#
|
||||
52 - and n# n#
|
||||
53 - or n# n#
|
||||
54 - xor n# n#
|
||||
55 - not n# n#
|
||||
|
||||
--------------------------------------
|
||||
|COMPARE AND JUMP
|
||||
--------------------------------------
|
||||
CMP_EQUAL
|
||||
CMP_NOT_EQUAL
|
||||
CMP_GREATER
|
||||
CMP_GREATER_EQUAL
|
||||
CMP_LESS
|
||||
CMP_LESS_EQUAL
|
||||
-------------------------------------
|
||||
|
||||
56 - cmp n# n#
|
||||
57 - cmp$ s# s#
|
||||
58 - cmp_u n# n#
|
||||
|
||||
59 - jmp n#
|
||||
60 - jmp @[address]
|
||||
61 - je n#
|
||||
62 - je @[address]
|
||||
63 - jne n#
|
||||
64 - jne @[address]
|
||||
65 - jg n#
|
||||
66 - jg @[address]
|
||||
67 - jge n#
|
||||
68 - jge @[address]
|
||||
69 - jl n#
|
||||
70 - jl @[address]
|
||||
71 - jle n#
|
||||
72 - jle @[address]
|
||||
|
||||
--------------------------------------
|
||||
|OBJECTS (USER TYPES AND ARRAYS)
|
||||
--------------------------------------
|
||||
OBJ_CURRENT_POSITION
|
||||
OBJ_CURRENT_TYPE
|
||||
--------------------------------------
|
||||
|
||||
73 - obj_num !id
|
||||
74 - obj_num1 !id n# (n# is the first dimension)
|
||||
75 - obj_num2 !id n# n#
|
||||
76 - obj_num3 !id n# n# n#
|
||||
|
||||
77 - obj_str !id
|
||||
78 - obj_str1 !id n# (n# is the first dimension)
|
||||
79 - obj_str2 !id n# n#
|
||||
80 - obj_str3 !id n# n# n#
|
||||
|
||||
81 - obj_usr !id
|
||||
82 - obj_usr1 !id n# (n# is the first dimension)
|
||||
83 - obj_usr2 !id n# n#
|
||||
84 - obj_usr3 !id n# n# n#
|
||||
|
||||
85 - obj_get n#
|
||||
86 - obj_get$ s#
|
||||
|
||||
87 - obj_set n#
|
||||
88 - obj_set s$
|
||||
|
||||
89 - clear_obj
|
||||
|
||||
90 - dim_type !id raw_number (user_type)
|
||||
91 - dim_type1 !id raw_number (user type) n# (dim1)
|
||||
92 - dim_type2 !id raw_number (user type) n# (dim1) n# (dim2)
|
||||
93 - dim_type3 !id raw_number (user type) n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
94 - dim_num1 !id n# (dim1)
|
||||
95 - dim_num2 !id n# (dim1) n# (dim2)
|
||||
96 - dim_num3 !id n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
97 - dim_str1 !id n# (dim1)
|
||||
98 - dim_str2 !id n# (dim1) n# (dim2)
|
||||
99 - dim_str3 !id n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
--------------------------------------------
|
||||
|STACKS
|
||||
--------------------------------------------
|
||||
<STACK> NUM_STACK
|
||||
<STACK> STR_STACK
|
||||
--------------------------------------------
|
||||
|
||||
100 - delete !id
|
||||
101 - delete$ !id
|
||||
|
||||
102 - push n#
|
||||
103 - push !id
|
||||
|
||||
104 - push$ s#
|
||||
105 - push$ !id
|
||||
|
||||
106 - push_empty$
|
||||
|
||||
107 - pop n#
|
||||
108 - pop !id
|
||||
|
||||
109 - pop$ s$
|
||||
110 - pop$ !id
|
||||
|
||||
111 - get_stack_size n#
|
||||
112 - get_stack_size$ n#
|
||||
|
||||
113 - clear_stack
|
||||
114 - clear_stack$
|
||||
|
||||
---------------------------------------------
|
||||
|LOOP
|
||||
---------------------------------------------
|
||||
<STACK> LOOP_STACK
|
||||
---------------------------------------------
|
||||
|
||||
115 - while n#
|
||||
116 - wend @address 'using jmp in parser for now
|
||||
|
||||
117 - for !id n# (starting value) n# (ending value) n#(step value)
|
||||
118 - next @address
|
||||
|
||||
119 - do
|
||||
120 - loop
|
||||
121 - loop_while n#
|
||||
122 - loop_until n#
|
||||
|
||||
123 - pop_loop_stack
|
||||
|
||||
------------------------------------------
|
||||
|FUNCTIONS AND SUB ROUTINES
|
||||
------------------------------------------
|
||||
<STACK> FUNCTION_STACK
|
||||
------------------------------------------
|
||||
|
||||
124 - gosub @[address]
|
||||
125 - return
|
||||
|
||||
-----------------------------------------
|
||||
|POINTERS
|
||||
-----------------------------------------
|
||||
126 - ptr !id n#
|
||||
127 - ptr$ !id s#
|
||||
|
||||
------------------------------------------
|
||||
|ADDED STUFF 'Because I didn't plan this design that well
|
||||
------------------------------------------
|
||||
|
||||
128 - print n#
|
||||
129 - print$ s#
|
||||
130 - func raw_number (built-in function index)
|
||||
131 - push raw_number
|
||||
132 - println
|
||||
133 - mov n# %CMP_FLAG
|
||||
134 - cmp n# raw_number
|
||||
135 - mov_arr n# !id
|
||||
136 - mov_arr$ s# !id
|
||||
137 - pop_ptr n#
|
||||
138 - preset !id
|
||||
139 - preset$ !id
|
||||
|
||||
140 - redim1 !id n#
|
||||
141 - redim2 !id n# n#
|
||||
142 - redim3 !id n# n# n#
|
||||
|
||||
143 - redim1$ !id n#
|
||||
144 - redim2$ !id n# n#
|
||||
145 - redim3$ !id n# n# n#
|
||||
|
||||
146 - for_offset_arr1 n#
|
||||
147 - for_offset_arr2 n# n#
|
||||
148 - for_offset_arr3 n# n# n#
|
||||
|
||||
149 - for_offset_0
|
||||
|
||||
150 - end_x n#
|
||||
|
||||
151 - lval n#
|
||||
152 - lval !id
|
||||
153 - lval @[address]
|
||||
|
||||
154 - lval$ s#
|
||||
155 - lval$ !id
|
||||
|
||||
// ---- New in 4.0 ---------
|
||||
156 - obj_usr_n !id
|
||||
157 - obj_usr_n1 !id n#
|
||||
158 - obj_usr_n2 !id n# n#
|
||||
159 - obj_usr_n3 !id n# n# n#
|
||||
|
||||
160 - obj_usr_s !id
|
||||
161 - obj_usr_s1 !id n#
|
||||
162 - obj_usr_s2 !id n# n#
|
||||
163 - obj_usr_s3 !id n# n# n#
|
||||
|
||||
164 - obj_usr_get n#
|
||||
165 - obj_usr_get s#
|
||||
166 - obj_usr_get u# // gets the value and sets the reference
|
||||
|
||||
167 - uref_ptr !id u#
|
||||
|
||||
168 - mov_type !id u# //copy user types and arrays
|
||||
|
||||
169 - push_t u#
|
||||
170 - push_t !id
|
||||
|
||||
171 - pop_t u#
|
||||
172 - pop_t !id
|
||||
|
||||
173 - push_t_null
|
||||
|
||||
174 - delete_t !id
|
||||
|
||||
175 - dim_type u# raw_number (user_type)
|
||||
176 - dim_type1 u# raw_number (user type) n# (dim1)
|
||||
177 - dim_type2 u# raw_number (user type) n# (dim1) n# (dim2)
|
||||
178 - dim_type3 u# raw_number (user type) n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
179 - dim_tfield raw_number (user_type) raw_number (member_type) raw_number (member_index) raw_number (dimensions) n# (dim1) n# (dim2) n# (dim3)
|
||||
|
||||
180 - obj_usr_init !id
|
||||
181 - obj_usr_init1 !id n# (n# is the first dimension)
|
||||
182 - obj_usr_init2 !id n# n#
|
||||
183 - obj_usr_init3 !id n# n# n#
|
||||
|
||||
184 - obj_usr_init u#
|
||||
185 - obj_usr_init1 u# n# (n# is the first dimension)
|
||||
186 - obj_usr_init2 u# n# n#
|
||||
187 - obj_usr_init3 u# n# n# n#
|
||||
|
||||
188 - preset_t !id raw_number (user_type)
|
||||
189 - preset_t1 !id raw_number (user_type) n#
|
||||
190 - preset_t2 !id raw_number (user_type) n# n#
|
||||
191 - preset_t3 !id raw_number (user_type) n# n# n#
|
||||
|
||||
|
||||
Reference in New Issue
Block a user