-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
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)
then, is compiled into:
MOVLW 00Ah
MOVLW I0
GOTO __LOOP1014
__LOOP1014
MOVF I0,W
MOVWF L0
MOVLW 000h
SUBWF L0,W
BTFSC STATUS,Z
GOTO _ELSE10
RETLW 000h
_ELSE10
MOVLW 001h
SUBWF L0,W
MOVWF L1
MOVF L1,W
MOVWF I0
GOTO __LOOP1014
Problem
There are unnecessary instructions in the compiled assembly compared with the case using DECFSZ instruction.
- get from and put into an input pseudo-register
- the first
GOTOinstruction - a conditional branch with
SUBWFandBTFSCinstructions SUBWFinstruction for decrement
Goal
Make loop forms compiled into instructions using DECFSZ instruction.
MOVLW 00Ah
MOVWF L0
__LOOP
DECFSZ L0,F
GOTO __LOOP
RETLW 000h
Approach
The following approaches are considerable:
- introducing
loopsyntax, not as a PIC macro - identifying loop structure to be optimized (chains of recurrences?)
Notes
There are some notes.
- updating
mdelay1function's magic number
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels