User Tools

Site Tools


notes:comporg:spring2024:projects:pncx

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:spring2024:projects:pncx [2024/04/24 20:53] – [timing] wgates1notes:comporg:spring2024:projects:pncx [2024/04/24 23:18] (current) – [dmorey2 pnc2 runtimes] dmorey2
Line 246: Line 246:
  
 =====Array in ASM===== =====Array in ASM=====
 +While Sieve of Eratosthenes might be easier to implement compared to pnc1 it does require knowing how to create an array in assembly which can be challenging if it has been a while sense you messed around with them. First will take a look at the array that we want to create in C and convert it into asm.
 +
 +Here is the set up of the array in C:
 +<code C>
 +    int [8193]primeAr; // Creating array
 +    
 +    // Filling primeAr with numbers from 2 to upperRange
 +    for (int pop=2; pop <= upperBound; pop++)
 +    {
 +        primeAr[pop]=pop;
 +    }
 +</code>
 +
 +Lets look at what is happening here, so we have created an array called primeAr and we have a loop that starts at 2 and goes till upperBound which could be 1024, 2048, and so on. Inside the loop, we are specifying the index at a given point in the array and assigning it pop. This is populating our array going 2,3,4,5,...upperBound which will be important for the logic later down the line.
 +
 +Now lets look at that in asm:
 +<code asm>
 +    mov R8, primeAr ; Starting point goes into R8
 +    iadd R8, 2      ; Incrementing R8 by 2
 +    mov R9, 2       ; starting point/number (pop in C)
 +
 +_bLoop:
 +    ; Loop condition
 +    mov R13, R9
 +    ile R13, R2
 +    jf R13, _bLoopEnd
 +
 +    mov [R8], R9 ; R9 moved into R8 array at current index
 +    iadd R8, 1   ; Increment memory address
 +    iadd R9, 1   ; Increment loop
 +
 +    jmp _bLoop ; Back to start of loop
 +
 +_bLoopEnd:
 +</code>
 +
 +As you can see the logic is very similar but just knowing how to write it might be the hard part but after doing a couple look overs and experimenting it will click.
 +
  
 ====wedge pnc1 runtimes==== ====wedge pnc1 runtimes====
Line 292: Line 330:
 ====dmorey2 pnc1 runtimes==== ====dmorey2 pnc1 runtimes====
 {{:notes:comporg:spring2024:projects:meta-chart.png?400|}} {{:notes:comporg:spring2024:projects:meta-chart.png?400|}}
 +
 +====dmorey2 pnc2 runtimes====
 +{{:notes:comporg:spring2024:projects:meta-chart_1_.png?400|}}
 ====rspringe Runtimes==== ====rspringe Runtimes====
 ===pnc0=== ===pnc0===
Line 298: Line 339:
 {{:notes:comporg:spring2024:projects:rspringe_pnc1_graph.png?400|}} {{:notes:comporg:spring2024:projects:rspringe_pnc1_graph.png?400|}}
 ===pnc2=== ===pnc2===
 +{{:notes:comporg:spring2024:projects:rspringe_pnc2_graph_-_1.png?400|}} 
 +{{:notes:comporg:spring2024:projects:rspringe_pnc2_graph_-_2.png?400|}}
notes/comporg/spring2024/projects/pncx.1714006394.txt.gz · Last modified: 2024/04/24 20:53 by wgates1