======BIA0====== ====Arrays of Structs in Assembly==== In Breakout coded in C, we used an array of brick structs to keep track of all the bricks on the field. When porting over to assembly, the approach needs to be changed due to a multitude of factors. Arrays don't formally exist in assembly. Since in array is simply an unchanging space of sequential memory, the stack must include the data for all the bricks in order. For breakout, each brick has five properties: - X-axis Position - Y-axis Position - Color - Health - Visibility Toggle 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): mov R0, BP isub R0, 24 mov R10, R0 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: isub R10, 5 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.