Array: Difference between revisions

Content added Content deleted
m (→‎Assembly: accidentally deleted lang closer)
m (→‎Assembly: formatting)
Line 47: Line 47:
ArrayROM: db 0,5,10,15,20,25,30,35,40,45,50
ArrayROM: db 0,5,10,15,20,25,30,35,40,45,50
;on Commodore 64 (for example) this can be RAM but on the NES or something similar it would be read-only</lang>
;on Commodore 64 (for example) this can be RAM but on the NES or something similar it would be read-only</lang>



====Indexing====
====Indexing====
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.
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.



<lang 68000devpac>;68000 Assembly example
<lang 68000devpac>;68000 Assembly example