What you learn today
- Convert °C, K and °F
- Convert kPa to atm
- Store results in fixed registers
The first week is done: you know registers, numbers and basic math. Time to put it together. Projects are a bit bigger than exercises and consist of several milestones – each one is a test of its own, and you see right away which are green.
The task
A chip should convert readings so you can compare them with tables from the internet or from friends. Two values come in:
| Register | Content |
|---|---|
r0 | temperature in °C |
r3 | pressure in kPa |
In the game a sensor would deliver the values. Here the test sets the registers before your program starts – so you can focus on the math.
The formulas
| Target | Calculation |
|---|---|
| Kelvin | °C + 273.15 |
| Fahrenheit | °C · 1.8 + 32 |
| Atmospheres | kPa / 101.325 |
| bar | kPa / 100 |
Fahrenheit needs two instructions, because there are no formulas with brackets. Compute into the target register and keep working there:
mul r2 r0 1.8
add r2 r2 32
Milestones
r1= temperature in Kelvinr2= temperature in Fahrenheitr4= pressure in atmospheresr5= pressure in bar- Everything together: a frosty Mars morning at −33 °C and 0.6 kPa
Do not overwrite r0 and r3 – you need the inputs for several calculations. An endless loop is not needed yet, that comes in week 3.
101.325 kPa is one standard atmosphere. In the game a well-tuned room sits roughly there.
Diagram
Project task
Task
r0 holds a temperature in °C, r3 a pressure in kPa (set by the test).
r1= Kelvinr2= Fahrenheitr4= atmospheres (kPa / 101.325)r5= bar (kPa / 100)
Milestones
- Milestone 1: Kelvin
- Milestone 2: Fahrenheit
- Milestone 3: atmospheres
- Milestone 4: bar
- Milestone 5: Mars morning at −33 °C and 0.6 kPa
Hints
Hint 1
Kelvin: add r1 r0 273.15.
Hint 2
Fahrenheit in two lines: mul r2 r0 1.8, then add r2 r2 32.
Hint 3
Pressure: two div with r3 as input.
Quiz
2 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed all milestones of the project
- 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