You are looking at lesson 3. Your place is still Practice test 1, task 1: About.
Extra: to the processor, if, loops and switch are comparisons (cmp) and jumps (jmp, jle, jge…). Find them in the assembly of practice/03/main.c.
Extra. Not graded. How does the processor run if, loops and switch?
Open the tool window's Assembly tab (topic 2's extra step explains how to read it). On the left is your practice/03/main.c.
The processor has no if and no while. It has two commands:
cmp a, b compares two numbers and remembers the result;jmp always jumps, while jl, jle, jg, jge, je, jne only jump when the last comparison was <, ≤, >, ≥, =, ≠ respectively.Labels such as .L18: are places to jump to.
if (grade < lowest) becomes cmp and jge: a jump over the assignment when the condition is not met. The compiler turns the condition around: it has to jump when lowest = grade; must not run.for loop: the assignment i = 1, a jump down to the condition, and the condition (cmp and jle back up) sits after the loop body. i++ is the add ..., 1 just before the condition.grade < 5 becomes cmp ..., 4 and jg: for integers, "< 5" is the same as "≤ 4".switch becomes a jump table: 5 is subtracted from grade, and the number 0–5 picks one of six addresses in the table. One check instead of six comparisons.Switch to -O1: i, sum, lowest and the rest live in registers, so the loop is shorter and the order of the C lines mixes in the instructions.
C source main.c
x86-64 assembly -O0
x86-64 assembly -O1
Each one ticks itself when you do it.
All six done. You know your way around.
It is laid out like CLion: the same panels in the same places. This tour shows each one, and you can reopen it any time with Tour.
Switches the left panel: Lesson plan, Project files, Changes. Click the active icon again to hide the panel.
In CLion: the tool window bar runs down the left edge, too.
This part is not on this task: it appears when a task needs it.
Every task in this lesson. Now marks your place. Clicking a task only lets you look; it never moves your place. Project files and Changes open here too.
In CLion: this spot holds the Project view (the file tree).
This part is not on this task: it appears when a task needs it.
Opens the file for your task by itself. A tab appears for each file the step opens. The breadcrumbs above the code show the folder.
In CLion: the same editor tabs and breadcrumbs.
This part is not on this task: it appears when a task needs it.
Diff shows what changed, like git diff: red is the old code, green the new.
In CLion: the diff view in the Commit window looks the same.
This part is not on this task: it appears when a task needs it.
Terminal for build commands, Database to see your tables. They open by themselves when a task needs them. Drag the top edge to resize.
In CLion: Terminal, and the Database tool window.
This part is not on this task: it appears when a task needs it.
What to do now, right above the code, so you never miss it. Numbered notes in the code explain the important lines. Details shows what you should see and a hint.
In CLion: no equivalent: this is your lecturer's guide.
This part is not on this task: it appears when a task needs it.
Done is the only button that moves you forward. Look back lets you review without losing your place.
This part is not on this task: it appears when a task needs it.
Guided, Focus code or Floating. You can drag the panel edges too. Your layout is remembered for next time.
In CLion: you can also rearrange and hide tool windows.
This part is not on this task: it appears when a task needs it.
Six small missions. Each one ticks itself when you do it, so you know you have found everything.