What you learn today
- Breqz, brnez, brltz, brgtz, brlez, brgez and brnan
- Skip a line
Yesterday you compared two values relatively. Often one of them is zero: is the deviation negative? Has the counter run out? Is the reading NaN? That is what the z forms are for.
The family against zero
| Instruction | jumps by n lines if |
|---|---|
breqz a n | a = 0 |
brnez a n | a ≠ 0 |
brltz a n | a < 0 |
brgtz a n | a > 0 |
brlez a n | a ≤ 0 |
brgez a n | a ≥ 0 |
brnan a n | a is NaN |
brnan is the relative counterpart of bnan. There is no brnanz and no bnanz.
Skipping one line
The most common pattern: a default value comes first, one line changes it, and the relative branch decides whether that line runs.
sub dev TARGET press # positive = too little pressure
move mode Vent.Inward # default: extract
brlez dev 2 # not too little: leave the line out
move mode Vent.Outward # too little: blow in
With brnan you guard a whole block. The distance then reaches past the block:
move on 0
brnan press 3 # no reading: leave out two lines
sub dev TARGET press
move on 1
Calculate first, then check against zero
The z forms show their strength when you build the deviation beforehand, such as sub dev target actual. After that only the sign decides. It is the same principle as the set instructions against zero from week 4.
With NaN no comparison jumps, not even brgez or brlez. Only brnan jumps. If the unsafe action sits in the skipped line, that is good. If it sits before it, it runs on NaN.
Note in the comment of every relative branch where it leads, such as # -> sbn. Whoever changes the code later then sees which distance has to move along.
The chip writes Mode only when it changes: every write, even with the same value, resets the active vent's target pressures to their defaults (day 51). breqz old 2 then skips exactly that one line. The three branches before land on the comment and run into this block from there.
Diagram
Exercise
Task
Gas sensor “Lager” and active vent “Lagerlueftung” (StructureActiveVent). Target: 100 kPa, ±5 kPa without action.
- below 95 kPa:
On1,ModeVent.Outward(blow in) - above 105 kPa:
On1,ModeVent.Inward(extract) - in between and on sensor failure:
On0
Use only relative branches against zero (breqz … brgez, brnan), no absolute comparison jumps.
Hints
Hint 1
brnan press … jumps on failure to the first sbn line – count the lines exactly.
Hint 2
Deviation: sub dev TARGET press. Whether it exceeds the band: abs, sub … BAND, then brlez.
Hint 3
Direction: brgtz dev 2 skips move mode Vent.Inward when there is too little pressure.
Quiz
4 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