You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Situation
The language's loop form, currently implemented as a PIC macro, is compiled into instructions including SUBWF, BTFSC and a recursive function call.
For example, the following expression:
(loop 10
0) ; nop
is expanded into:
(let ((_loop (i)
(if (= i 0)
0
(progn
0
(_loop (- i 1))))))
(_loop 10)
When a let bound variable is used as a function call's parameter in a LOOP syntax, it is assigned to a local pseudo-register, not to an input pseudo-register.
For example:
(let ((x (foo)))
(loop 10
(bar x)))
the let bound variable x is assigned to L0, not to I0.
Alive register
A register used as a loop counter in LOOP syntax keeps alive in the LOOP's body part.
For example,
(let ((x 10))
(loop x
(do-something)))
the local pseudo-register L0, assigned for x as a loop counter, keep alive in the loop and can not be assigned again.
NULL destination
For LOOP bodies, newly provided is NULL destination (:non-tail :null) which does not move and discards results of LOOP bodies.
Situation
The language's
loop
form, currently implemented as a PIC macro, is compiled into instructions includingSUBWF
,BTFSC
and a recursive function call.For example, the following expression:
is expanded into:
then, is compiled into:
Problem
There are unnecessary instructions in the compiled assembly compared with the case using
DECFSZ
instruction.GOTO
instructionSUBWF
andBTFSC
instructionsSUBWF
instruction for decrementGoal
Make
loop
forms compiled into instructions usingDECFSZ
instruction.Approach
The following approaches are considerable:
loop
syntax, not as a PIC macroNotes
There are some notes.
mdelay1
function's magic numberThe text was updated successfully, but these errors were encountered: