User Tools

Site Tools


notes:comporg:spring2025:projects:mtb3

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:comporg:spring2025:projects:mtb3 [2025/03/21 18:25] – [manifestation in memory] cgrant9notes:comporg:spring2025:projects:mtb3 [2025/04/03 04:11] (current) – [logic for accessing] bdildine
Line 5: Line 5:
 ====manifestation in memory==== ====manifestation in memory====
 When looking at the bricks in breakout, it makes sense to see them as an array, which are a very simple concept in assembly, as it is just a contiguous chunk in memory. That said, when initializing our block field, we are just initializing an area in memory with specific values to access later on.\\ When looking at the bricks in breakout, it makes sense to see them as an array, which are a very simple concept in assembly, as it is just a contiguous chunk in memory. That said, when initializing our block field, we are just initializing an area in memory with specific values to access later on.\\
-When looking to initialize our memory, we have to consider everything we may use for our blocks, which may be just an xpos, ypos, and active flag, and give enough space to hold everything. There are multiple ways of going about this depending to the constraints you have; if you are looking for space efficiency, you may want to pack your data into one word each, then decoding later when we need to use it; if you are looking for ease of use, you may just want to give each attribute its own word in memory. To take the latter approach, you will want to initialize each attribute based on a starting position, then move that starting position along to affect each block. This may look like+When looking to initialize our memory, we have to consider everything we may use for our blocks, which may be just an xpos, ypos, and active flag, and give enough space to hold everything. There are multiple ways of going about this depending to the constraints you have; if you are looking for space efficiency, you may want to pack your data into one word each, then decoding later when we need to use it; if you are looking for ease of use, you may just want to give each attribute its own word in memory. To take the latter approach, you will want to initialize each attribute based on a starting position, then move that starting position along to affect each block. This may look like:
 <code> <code>
 _init: _init:
Line 22: Line 22:
 </code> </code>
 ====logic for accessing==== ====logic for accessing====
 +If you gave each attribute of the brick its own memory address (for example active flag, xpos, ypos) we can access them by going back to that address.
 +If you used 0x00000000 as your starting address for defining the brick field for example, you would set a register to that memory address and then read from it and its following addresses as such:
 +<code>
 +     mov  R0,        0x00000000  ; move starting address into R0
  
 +_brick_activeflag: 
 +     mov  R1,        [R0]        ; load the value in the active flag memory address for the chosen brick 
 +     ieq  R1,        1           ; display the brick if the flag is active 
 +     jt   R1,        _display_brick 
 +     ; repeat loop if not active 
 +</code> 
 +Similarly when displaying the bricks we can use [R0+1] and [R0+2]. 
 +Since R0 is the memory address of our brick and each brick has three addresses (active flag, xpos, ypos), 
 +[R0] is the active flag [R0+1] is the xpos and [R0+2] is the ypos.
notes/comporg/spring2025/projects/mtb3.1742581556.txt.gz · Last modified: 2025/03/21 18:25 by cgrant9