Array: Difference between revisions

m
Line 49:
Almost all assembly languages have a method of loading from a memory address offset by some sort of variable amount. That offset is the index into the array. Depending on the size of each element that index is multiplied by the number of bytes each element takes up. What constitutes an "element," "row," or "column" of the array is entirely decided by the programmer. Arrays in assembly are always zero-indexed.
 
====Indexing====
 
<lang 68000devpac>;68000 Assembly example
LEA myArray,A0 ;loading a labeled array name like this loads the address of the zeroth element
Line 70:
 
 
====Iteration====
 
Iteration over the elements of an array is fairly straightforward.
<lang 68000devpac>;68000 Assembly example
Line 85:
 
 
====Skip-Counting====
 
Skipping elements can be easily done with a "dummy read," whereby an auto-incrementing/decrementing addressing mode is used solely for updating the pointer, or by incrementing/decrementing a loop counter multiple times per loop.
<lang asm>;8086 Assembly example
Line 97:
Implementation of a reverse array slice such as <code>a[100:0:-2]</code> example for [[Python]] is much more difficult. First of all, computers cannot implicitly understand the concept of the "end" of an array. The start of an array is easy for a computer to grasp, it is simply a pointer to its first element. However, encoding an array's end point requires some form of metadata, such as a null terminator or an additional variable representing the array's maximum size. High-level languages typically handle this automatically.
 
====Element Access====
Access of an individual element of an array depends on the language.
<lang asm>;6502 Assembly
1,489

edits