User Tools

Site Tools


notes:comporg:fall2023:projects:bia0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
notes:comporg:fall2023:projects:bia0 [2023/10/26 00:27] – [Arrays of Structs in Assembly] walleynotes:comporg:fall2023:projects:bia0 [2023/10/26 00:33] (current) – [Arrays of Structs in Assembly] walley
Line 13: Line 13:
 Accessing an individual array element uses an ID value to get that position's specific data. In Assembly, we use a register to hold the memory address of a given element's first property. Here's an example in practice: Accessing an individual array element uses an ID value to get that position's specific data. In Assembly, we use a register to hold the memory address of a given element's first property. Here's an example in practice:
  
 +The first Brick's X Position is in ''BP-24''(The 24th element in the Stack). We copy this memory address and store it within a general register (preferably a later one so its not likely to get overwritten):
 +<code>
 +mov  R0,  BP
 +isub R0,  24
 +mov  R10, R0
 +</code>
  
 +Within our for-loop we use to access all the bricks sequentially, we reference individual elements through R10. (i.e. ''[R10-3]'' is the current Brick's color value.)
 +
 +When moving from one brick to the next, we directly adjust the memory address stored in R10. It's simple in practice:
 +<code>
 +isub R10, 5
 +</code> 
 +This reference point moves from the current Brick's X Position, to the next Brick's X Position. This way, our relative point R10 doesn't change when inside any brick. This allows for loops to work with arrays.
notes/comporg/fall2023/projects/bia0.1698280077.txt.gz · Last modified: 2023/10/26 00:27 by walley