Array: Difference between revisions
m
→Assembly: clarification on rom/ram arrays
Puppydrum64 (talk | contribs) m (→Assembly) |
Puppydrum64 (talk | contribs) m (→Assembly: clarification on rom/ram arrays) |
||
Line 41:
* [[letter frequency]]
===[[Assembly]]===
An array is simply a sequence of values stored in consecutive memory locations. Its beginning is typically defined with some sort of label that points to the address where that array is stored.
<lang 6502asm>;6502 Assembly example
ArrayRAM equ $00 ;the beginning of an array, stored in zero page RAM
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
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.
|