What you learn today
- Write comments with #
- 128 lines, 4096 characters, 90 characters per line
- What counts towards them
A program you no longer understand after three weeks is a broken program. Comments help against that. But they cost space, and space on the chip is tight.
Comments
The chip ignores everything from # to the end of the line. A comment may fill a whole line or sit behind an instruction:
# pressure in bar for the hallway display
div r1 r0 100 # 100 kPa = 1 bar
Good comments say why something is the way it is or what a number means. # r1 = r0 / 100 helps nobody, the instruction already says that.
Special characters such as German umlauts or the degree sign turn into “?” in the game, because the game only stores ASCII. Stick to plain letters in comments: # deg C instead of °C.
The three limits
| Limit | Value | what counts |
|---|---|---|
| Lines | 128 | every line: instructions, blank lines, comment lines, labels, define, alias |
| Characters in total | 4096 | every character, including spaces and comments |
| Characters per line | 90 | the whole line including its comment |
More does not fit on the chip. There is no trick that makes a line “not count”.
Which limit breaks first?
Do the math: 4096 characters divided by 128 lines is 32 characters per line. An instruction like add r1 r0 273.15 has 16 characters. With a comment behind it you quickly reach 45. That is why with commented programs the character limit is almost always the binding one, not the line count.
# --- conversion for the status panel ---
sub r1 r0 273.15 # Kelvin to degrees C
mul r2 r1 1.8 # Fahrenheit, step 1
add r2 r2 32 # Fahrenheit, step 2
Four lines, a good 140 characters. Only 44 of them are instructions.
When it gets tight
- Shorten comments, cut filler words. “deg C” instead of “converted to degrees Celsius”.
- Use blank lines sparingly.
- The game version from the last lesson strips comments and blank lines for the chip. You keep the commented version for yourself.
- The IC10 coder always shows lines, characters and width in the bar at the top.
Until May 2024 the in-game editor was only 64 characters wide. Old code from the internet is therefore often wrapped noticeably narrow.
Diagram
Exercise
Task
The starter code converts a temperature, but cannot go onto the chip like this:
- The first line is longer than 90 characters. Shorten the comment.
- A comment contains the special character °. Leave it out.
- Add the missing calculation:
r2= temperature in Fahrenheit (°C · 1.8 + 32).
r0 is the temperature in Kelvin (set by the test), r1 in °C.
Hints
Hint 1
The IC10 coder shows the width of the longest line at the top.
Hint 2
“°F” simply becomes “F”.
Hint 3
Fahrenheit in two lines: mul r2 r1 1.8, then add r2 r2 32.
Quiz
5 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in