add pdf generation
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
---
|
||||
path: /elektro/hr/rts10/
|
||||
tags: kladjes, elektro, elektro/hr, elektro/hr/rts10
|
||||
auther:
|
||||
- Finley van Reenen (0964590@hr.nl)
|
||||
auther_short: "E.L.F. van Reenen"
|
||||
---
|
||||
|
||||
# Assembly Assignments
|
||||
[parent](/lLnsoW2yQlWpblaVBRFsYw)
|
||||
|
||||
# Assembly Assignment
|
||||
|
||||
This is the first report for _realtime systems 10_. I needed to do the following assignments:
|
||||
|
||||
@@ -38,8 +37,8 @@ I applied the same fix as last year. In the debug config, replace the `\` with a
|
||||
|
||||
The algorithm in question is given in C code.
|
||||
|
||||
```c-like=
|
||||
unsigned int multiply(unsigned int a , unsigned int b)
|
||||
```c {.numberLines}
|
||||
unsigned int multiply(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int m = 0;
|
||||
for (unsigned int i = 0; i != a; i ++)
|
||||
@@ -52,8 +51,8 @@ unsigned int multiply(unsigned int a , unsigned int b)
|
||||
|
||||
This code can be simplified without changing the algorithm by replacing the variable `i` with `b`. This will result in the following code.
|
||||
|
||||
```c-like=
|
||||
unsigned int multiply ( unsigned int a , unsigned int b)
|
||||
```c {.numberLines}
|
||||
unsigned int multiply(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int m = 0;
|
||||
for (; b > 0; b --)
|
||||
@@ -66,7 +65,7 @@ unsigned int multiply ( unsigned int a , unsigned int b)
|
||||
|
||||
This is also the code I have implemented. The compiler puts _a_ in `R0` and _b_ in `R1`, I accepted them in place and used `R2` for _m_. At the end _m_ (`R2`) is moved to `R0` to set it as the return value.
|
||||
|
||||
```ass=
|
||||
```asm {.numberLines}
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
.syntax unified
|
||||
@@ -88,8 +87,8 @@ mul_exit:
|
||||
|
||||
a better representation of the essembly code in C would be:
|
||||
|
||||
```c-like=
|
||||
unsigned int multiply ( unsigned int a , unsigned int b)
|
||||
```c {.numberLines}
|
||||
unsigned int multiply(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int m = 0;
|
||||
if (b == 0) {
|
||||
@@ -98,7 +97,7 @@ unsigned int multiply ( unsigned int a , unsigned int b)
|
||||
|
||||
do
|
||||
{
|
||||
m = m + b;
|
||||
m = m + a;
|
||||
b --;
|
||||
} while (b > 0)
|
||||
|
||||
@@ -117,7 +116,7 @@ It does not take the branch at line 10 and at line 14 it takes the branch 65535
|
||||
|
||||
Now a smarter version.
|
||||
|
||||
```c-like=
|
||||
```c {.numberLines}
|
||||
unsigned int multiply(unsigned int a , unsigned int b)
|
||||
{
|
||||
unsigned int m = 0;
|
||||
@@ -134,7 +133,7 @@ unsigned int multiply(unsigned int a , unsigned int b)
|
||||
}
|
||||
```
|
||||
|
||||
```asm=
|
||||
```asm {.numberLines}
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
.syntax unified
|
||||
@@ -162,8 +161,8 @@ bmul_exit:
|
||||
|
||||
a better representation of the essembly code in C would be:
|
||||
|
||||
```c-like=
|
||||
unsigned int multiply ( unsigned int a , unsigned int b)
|
||||
```c {.numberLines}
|
||||
unsigned int multiply(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int m = 0;
|
||||
if (b == 0) {
|
||||
@@ -192,7 +191,7 @@ There are 7 instructions in the loop where one only runs every `1` bit in `b`. T
|
||||
|
||||
## Assignment 10: Using your multiply function to calculate the dot product of two vectors
|
||||
|
||||
```c-like=
|
||||
```c {.numberLines}
|
||||
unsigned int dotProduct(unsigned int a[], unsigned int b[], size_t n)
|
||||
{
|
||||
unsigned int p = 0;
|
||||
@@ -206,7 +205,7 @@ unsigned int dotProduct(unsigned int a[], unsigned int b[], size_t n)
|
||||
|
||||
This function needs to call another and remember 5 variables (`*a`, `*b`, `n`, `p` and `i`). `R0` through `R3` are expected to change with a function call. There are only `R4` through `R7` left, only four spots. To solve this problem, I reversed the for loop by using n and decrementing it. This will not change the result since addition is not order sensitive. The code I implemented is the following.
|
||||
|
||||
```c-like=
|
||||
```c {.numberLines}
|
||||
unsigned int dotProduct(unsigned int a[] , unsigned int b[], size_t n)
|
||||
{
|
||||
unsigned int p = 0;
|
||||
@@ -225,7 +224,7 @@ unsigned int dotProduct(unsigned int a[] , unsigned int b[], size_t n)
|
||||
|
||||
My assembly code:
|
||||
|
||||
```asm=
|
||||
```asm {.numberLines}
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
.syntax unified
|
||||
@@ -252,5 +251,4 @@ dotp_loop:
|
||||
dotp_exit:
|
||||
MOVS.N R0, R7 // move m to R0
|
||||
POP.N {R4, R5, R6, R7, PC}
|
||||
BX.N LR
|
||||
```
|
||||
|
||||
16
report-1/assambly_report.md
Normal file
16
report-1/assambly_report.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
sub_title: "Real Time Systems 10"
|
||||
auther:
|
||||
- name: "Finley van Reenen (0964590)"
|
||||
email: "mail@lailatheelf.nl"
|
||||
name_short: "E.L.F. van Reenen"
|
||||
---
|
||||
|
||||
# Assambly Report
|
||||
|
||||
[toc]
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
@@ -146,7 +146,9 @@ while ((FLASH->ACR & /* ... */ ) == 0);
|
||||
Finaly we configur the PLL itself.
|
||||
|
||||
$$
|
||||
f_{(VCO\ clock)} = f_{(PLL\ clock\ input)} \cdot (\frac{PLLN}{PLLM}) \\
|
||||
f_{(VCO\ clock)} = f_{(PLL\ clock\ input)} \cdot (\frac{PLLN}{PLLM})
|
||||
$$
|
||||
$$
|
||||
f_{(PLL\ general\ clock\ output)} = \frac{f_{(VCO\ clock)}}{PLLP}
|
||||
$$
|
||||
|
||||
|
||||
Reference in New Issue
Block a user