-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
chapters/{memory-layout,stack}: Add tasks and reading material for C - Assembly interaction #24
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove all
utils/
folders becauseprintf32.asm
is no longer used and change the makefiles that include those files to be standalone. - Add the following line at the end of each task statement:
If you're having difficulties solving this exercise, go through [this](link to a relevant reading/ section) reading material
chapters/memory-layout/c-assembly-interaction/drills/tasks/cpp-obs/README.md
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/README.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I submitted my previous review too early. Below is the continuation:
- For all tasks mention the path where students can find the code (
drills/tasks/task-name/support/[file_name]
). - Use
Title Case
in all Markdown headings: https://en.wikipedia.org/wiki/Title_case. - Remove exercise numbers from
max-calls
. - Fix the linter errors [1]. Some of those coming from checkpatch are false positives, so you can ignore them.
- Change your commit message to
chapters/{memory-layout,stack}: Add tasks and reading material for C - Assembly interaction
and add a description of your changes.
[1] https://github.com/cs-pub-ro/hardware-software-interface/pull/24/checks
chapters/memory-layout/c-assembly-interaction/drills/tasks/include-fix/README.md
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/cpp-obs/README.md
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/regs-preserve/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/guides/students/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/readings/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/readings/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/readings/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/readings/README.md
Outdated
Show resolved
Hide resolved
e987016
to
3da3c28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few more suggestions. You haven't addressed all my previous comments yet. I pointed out which of them need addressing. I also made some additional suggestions.
...ory-layout/c-assembly-interaction/drills/tasks/cpp-obs/support/errors/c-calls-cpp/.gitignore
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/cpp-obs/README.md
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/cpp-obs/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/include-fix/README.md
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-assembly-calls/README.md
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls/solution/Makefile
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/stack-frame/solution/Makefile
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/regs-preserve/README.md
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/stack-frame/solution/print-hello.asm
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/regs-preserve/README.md
Outdated
Show resolved
Hide resolved
2134941
to
0aaf4a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pay attention to my older comments that you haven't addressed yet. Click "Resolve" when you apply one of them so you can keep track of them better. I also found a few other incongruencies, mostly related to Makefiles and .gitignores. The text and exercises seem good though.
@@ -0,0 +1,26 @@ | |||
# Compilator și flag-uri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump.
...-assembly-interaction/drills/tasks/max-assembly-calls/solution/max-assembly-calls-2/Makefile
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls-x64/solution/Makefile
Outdated
Show resolved
Hide resolved
@@ -0,0 +1 @@ | |||
/mainmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump. Also add this file to ../solution
.
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/Makefile
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls/.gitignore
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls/solution/Makefile
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/stack-frame/solution/Makefile
Outdated
Show resolved
Hide resolved
@@ -0,0 +1 @@ | |||
/main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump. And copy this file to ../solution/
chapters/stack/c-assembly-interaction/guides/students/README.md
Outdated
Show resolved
Hide resolved
And rebase the |
fba0644
to
ae10021
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good 👍
chapters/memory-layout/c-assembly-interaction/reading/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/reading/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/drills/tasks/regs-preserve/README.md
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls/README.md
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few more corrections. Besides those, fix the CI/CD errors:
- checkpatch fails for some Makefiles where
rm -f main main.o
can be replaced withrm -f main *.o
[1] - super-linter complains about block quotes where you can simply add
>
at the beginning of empty lines [2] - You can skip
spellcheck
after addressing all comments becausemainmax
is a false positive [3]
[1] https://github.com/cs-pub-ro/hardware-software-interface/actions/runs/10167959782/job/28121457526?pr=24
[2] https://github.com/cs-pub-ro/hardware-software-interface/actions/runs/10167959782/job/28121456962?pr=24
[3] https://github.com/cs-pub-ro/hardware-software-interface/actions/runs/10167959782/job/28121457272?pr=24
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls-x64/solution/.gitignore
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/max-c-calls-x64/support/.gitignore
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/stack-frame/solution/.gitignore
Outdated
Show resolved
Hide resolved
chapters/stack/c-assembly-interaction/drills/tasks/stack-frame/support/.gitignore
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/reading/README.md
Outdated
Show resolved
Hide resolved
chapters/memory-layout/c-assembly-interaction/reading/README.md
Outdated
Show resolved
Hide resolved
… to point to the path of the exercices. Also modified config.yaml and removed guides from this lab.
ae10021
to
bb5ca28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made suggestions for what needs to change for the linters to pass.
In addition, take care of the following:
- To fix
spellcheck
, make a PR to addextern
to this wordlist [1] andmainmax
to this one [2]. - Change your commit message to:
chapters/{memory-layout,stack}: Add tasks and reading material for C - Assembly interaction
Then add a description of the changes below and sign it with git commit -as
[1] https://github.com/open-education-hub/actions/blob/main/spellcheck/config/technical.txt
[2] https://github.com/open-education-hub/actions/blob/main/spellcheck/config/acronyms.txt
@@ -0,0 +1 @@ | |||
mainmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mainmax | |
mainmax | |
Add a newline at the end of this file
@@ -0,0 +1 @@ | |||
mainmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mainmax | |
mainmax | |
Add a newline at the end of this file
The printed message is not as expected because the assembly code is missing an instruction. | ||
|
||
Use GDB to inspect the address at the top of the stack before executing the `ret` statement in the `print_hello()` function. | ||
What does it point to? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it point to? | |
What does it point to? |
@@ -0,0 +1 @@ | |||
main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main | |
main | |
Add a newline at the end of this file
@@ -0,0 +1,18 @@ | |||
// SPDX-License-Identifier: BSD-3-Clause | |||
|
|||
extern int puts(const char *); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern int puts(const char *); | |
extern int puts(const char *str); |
According to the checkpatch error.
> **IMPORTANT:** | ||
> The return value of a function is placed in the `eax` register. | ||
|
||
# Maximum Computation Extension in Assembly with Call from C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Maximum Computation Extension in Assembly with Call from C | |
## Maximum Computation Extension in Assembly with Call from C |
> **TIP:** | ||
> In order to restore the stack to its state at the start of the current function, the `leave` statement relies on the function's pointer frame having been set. | ||
|
||
If you're having difficulties solving this exercise, go through [this relevant section](../../../reading/README.md#passing-parameters-from-c-to-the-assembly-procedure) reading material. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're having difficulties solving this exercise, go through [this relevant section](../../../reading/README.md#passing-parameters-from-c-to-the-assembly-procedure) reading material. | |
If you're having difficulties solving this exercise, go through [this relevant section](../../../reading/README.md#passing-parameters-from-c-to-the-assembly-procedure) reading material. | |
When C executes the call to `sum()`, it first pushes arguments on the stack in reverse order, then actually calls the procedure. | ||
Thus, upon entering the procedure body, the stack will be intact. | ||
|
||
Since the variables `a` and `b` are declared as `int` values, they will each use one word on the stack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the variables `a` and `b` are declared as `int` values, they will each use one word on the stack. | |
Since the variables `a` and `b` are declared as `int` values, they will each use one word on the stack. |
> pos: dd 0 | ||
> ``` | ||
> | ||
> This variable you will pass (by address) to the `get_max` call and by value to the `printf()` call for display. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> This variable you will pass (by address) to the `get_max` call and by value to the `printf()` call for display. | |
> This variable you will pass (by address) to the `get_max()` call and by value to the `printf()` call for display. |
|
||
Use GDB to inspect the address at the top of the stack before executing the `ret` statement in the `print_hello()` function. | ||
What does it point to? | ||
Track the values of the EBP and ESP registers during the execution of this function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Track the values of the EBP and ESP registers during the execution of this function. | |
Track the values of the `ebp` and `esp` registers during the execution of this function. |
@savacezarmarian14 address my last review and then we can merge this |
Prerequisite Checklist
Description of changes