takagi / pic

A native compiler for 8-bit PIC micro controllers written in Common Lisp.
MIT License
40 stars 3 forks source link

How should loop syntax behave when passed zero #10

Open takagi opened 9 years ago

takagi commented 9 years ago

The following code iterates DO-SOMETHING for 256 times, because loop syntax is compiled to a DECFSZ instruction and the result decrementing zero becomes 255.

(loop 0
  (do-something))

How should loop syntax behave when it is passed zero as its argument?

DECFSZ instruction The contents of register ‘f’ are decremented. ... If the result is ‘1’, the next instruction is executed. If the result is ‘0’, then a NOP is executed instead, ...