Difference between revisions of "Arrays"
Jump to navigation
Jump to search
(Created page with "Virtual Machine supports either one or two dimensional arrays. Each variable type can be declared as an array. Accessing indexes is done by pushing values to the stack. So for...") |
|||
Line 3: | Line 3: | ||
<code>int array[2][3];</code> accessing element <code>array[0][1]</code> is done by performing operations: | <code>int array[2][3];</code> accessing element <code>array[0][1]</code> is done by performing operations: | ||
− | < | + | <pre>PUSHII 0 |
+ | PUSHII 1 | ||
+ | PUSHV [array]</pre> | ||
− | <code> | + | where <code>[array]</code> is number of variable array in variable table. |
− | |||
− | |||
− | |||
− |
Revision as of 13:54, 15 July 2019
Virtual Machine supports either one or two dimensional arrays. Each variable type can be declared as an array. Accessing indexes is done by pushing values to the stack. So for an array:
int array[2][3];
accessing element array[0][1]
is done by performing operations:
PUSHII 0 PUSHII 1 PUSHV [array]
where [array]
is number of variable array in variable table.