You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a test function to raise the PendSV flag (in C and Assembly)
PendSV is a special software-initiated interrupt in the ARM chip architecture, needed to copy the context (stack and intermediate data) of tasks into RAM (after executing the PendSV interrupt handler, it is assumed that another task will be executed)
Copy file name to clipboardExpand all lines: doc/asm/create_tasks_explainig.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,11 @@ And here we go - look at `create_tasks.S` file - there's include! But...what the
6
6
What moves the data from .c-file into .h-file? Makefile does. And it does it with a regular expression: `'s/^-> \([^ ]*\) [\$$#]\?\([^ ]*\).*/#define \1 \2/p'`. This shit is absolutely fucked up. In two words it searches the string from .c-file where macro works and inserts needed data when it needs. Then, in the `gen_offsets.c` file are a couple of this things - and actually these data is Makefile searches for. This data what we can get after executing the macro
7
7
Let's break down the mechanics:
8
8
1. Search and Boundaries (.* at the beginning and end) .* at the beginning and end means "I don't care what comes before our -> arrow and what comes after the number." The compiler often adds tabs or comments on the same line. This expression tells sed to discard all unnecessary stuff and keep only what we'll extract into the "pockets."
9
-
2. Marker and Spaces (->[[:space:]]*). -> is our hard-coded "anchor." [[:space:]]* is a very important part. It means "any number of spaces or tabs." Different versions of gcc may indent the line after the arrow differently, and this command makes the search universal.
10
-
3. First Pocket: Constant Name (\([A-Z_0-9]*\)). \( ... \) are "remembering brackets" (pockets). Whatever ends up here, we'll later call it with \1.
11
-
[A-Z_0-9]* — we only allow uppercase letters, numbers, and underscores in the name. This is the standard for #define.
12
-
4. Garbage before a number ([#$$]\?). In ARM assembler, constants are often written as #12 or $12. [#$$]\?] says: "There might be a # or $ symbol here, or there might not be one (?)." We find this symbol, but don't put it in the pocket, thereby simply deleting it.
13
-
5. Second pocket: Value (\([0-9]*\)). \([0-9]*\) — we only take digits. This value will go in \2.
14
-
6. Replacement (/#define \1 \2/p). This is where the constructor is assembled. sed takes the word from the first pocket and the number from the second, then concatenates them into a ready-made C string: #define SCH_TASK_SIZE 12.
9
+
2. Marker and Spaces `(->[[:space:]]*). -> is our hard-coded "anchor." [[:space:]]*` is a very important part. It means "any number of spaces or tabs." Different versions of gcc may indent the line after the arrow differently, and this command makes the search universal.
10
+
3. First Pocket: Constant Name `(\([A-Z_0-9]*\))`. `\( ... \)` are "remembering brackets" (pockets). Whatever ends up here, we'll later call it with `\1. [A-Z_0-9]*` — we only allow uppercase letters, numbers, and underscores in the name. This is the standard for `#define`.
11
+
4. Garbage before a number `([#$$]\?)`. In ARM assembler, constants are often written as `#12` or `$12`. `[#$$]\?]` says: "There might be a # or $ symbol here, or there might not be one (?)." We find this symbol, but don't put it in the pocket, thereby simply deleting it.
12
+
5. Second pocket: Value `(\([0-9]*\))`. `\([0-9]*\)` — we only take digits. This value will go in \2.
13
+
6. Replacement `(/#define \1 \2/p)`. This is where the constructor is assembled. sed takes the word from the first pocket and the number from the second, then concatenates them into a ready-made C string: `#define SCH_TASK_SIZE 12`.
15
14
16
15
The p flag at the end (along with sed's -n switch) forces the utility to print only those lines where the replacement was successful. All other assembly code from gen_offsets.s is simply removed.
0 commit comments