-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lab/interactiune-c-assembly: Add inline exercises #193
base: master
Are you sure you want to change the base?
lab/interactiune-c-assembly: Add inline exercises #193
Conversation
48a637f
to
8f802ec
Compare
Adding 1-inline-for, 2-inline-rotate and 3-inline-rtdscp and reordering the exercises accordingly. Signed-off-by: Andreia Ocanoaia <[email protected]>
8f802ec
to
75a7501
Compare
include ../../utils/Makefile.generic | ||
|
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.
include ../../utils/Makefile.generic | |
include ../../utils/Makefile.generic |
You have 2 trailing newlines at the end of each Makefile. Remove one of them.
@@ -0,0 +1 @@ | |||
/inline_for.asm |
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.
/inline_for.asm | |
/inline_for |
Why .asm
?
@@ -0,0 +1 @@ | |||
/inline_rotate.asm |
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.
/inline_rotate.asm | |
/inline_rotate |
@@ -0,0 +1 @@ | |||
/inline_cpuid.asm |
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.
/inline_cpuid.asm | |
/inline_rdtscp |
@@ -0,0 +1,3 @@ | |||
PROGNAME := inline_rtdscp |
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.
PROGNAME := inline_rtdscp | |
PROGNAME := inline_rdtscp |
@@ -0,0 +1 @@ | |||
/inline_rotate.asm |
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.
/inline_rotate.asm | |
/inline_rotate |
> **NOTE:** Nu are sens să declarăm ca fiind inline funcțiile recursive. De ce? | ||
Acum este ușor să ghicim la ce se referă expresia “inline assembly”: un set de instrucțiuni assembly scrise ca funcții inline. Inline assembly este folosit ca o metoda de optimizare și este foarte des întâlnit în system programming. | ||
|
||
În programele C/C++ se pot insera instrucțiuni în limbaje de asamblare folosing cuvântul cheie “asm”. |
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.
În programele C/C++ se pot insera instrucțiuni în limbaje de asamblare folosing cuvântul cheie “asm”. | |
În programele C/C++ se pot insera instrucțiuni în limbaje de asamblare folosing cuvântul cheie "asm". |
Use ASCII quotes.
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.
rdtscp
places the timestamp counter in edx:eax
as a 64-bit number, not a string. In addition, it places the CPU number in ecx
, but since students aren't used to multicore operations yet, I think we should ignore this register and focus on edx:eax
. Change this exercise so that it uses rdtscp
to calculate the time spent on some operations, like a for loop doing whatever.
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.
There are two variants to the operation - rdtsc
and rdtscp
, where rdtscp
also adds the processor type, but more importantly also acts as a barrier, so measuring time should be more correct using it. However, measuring time using the TSC is non-trivial, since you also need to account for the increment frequency.
You will need to explain what the numbers actually mean, since they don't translate directly to either seconds (you need to extract the increment frequency from somewhere - e.g., the system's journal using something like journalctl -xe -n 10000 | grep clocksource
), nor processor clock cycles (most modern CPUs have invariant TSC, which means that the TSC is incremented at a frequency near the CPU's maximum frequency without turbo boosts, regardless of C/P/T states, which especially on laptops will rarely be the same as the actual CPU frequency).
This PR adds the following exercises for
interactiunea-c-assembly
lab: