4 badusage () { echo >&2 'bad usage'; exit 1; }
10 --by-opcode) cohere=$1; sortkey=1 ;;
11 --by-desc) cohere=$1; sortkey=29 ;;
12 --by-official) cohere=$1; sortkey=68 ;;
13 --macros) macros=true ;;
14 --descs) comment='' ;;
17 test $# = 1 || badusage
19 flags () { eval "flags_$1=$2"; }
46 if [ x$cohere != x ]; then
47 sed <$0 -e '1,/^#'$cohere'--/d; /^#--0--/,$d'
48 "$0" --descs | sort -t % -k 1.$sortkey
49 test "${PIPESTATUS[*]}" = "0 0"
50 sed <$0 -e '1,/^#--3--/d; /^#--0--/,$d'
59 local use=$1 new=$2 formargs=$3 notes=$4
60 eval "flags__use=\$flags_$use"
61 local fan="$(printf "%-6s %s" "$formargs" "$flags__use$notes")"
63 printf "$comment %-13s %-12s %-39s %s\n" \
64 "$new" "$fan" "$ds" "$use"
69 printf "%s\n" "$str" \
70 | sed -e 's/\b[a-z]\b/insn_aliases_arg_&/g'
74 local use=$1 new=$2 actargs=$3 formargs=$4
84 local use=$1 new=$2 actargs=$3 formargs=$4 notes="$5"
85 formargs=${formargs#,}
86 desc $use $new "$formargs" "$notes"
87 alias_r "$use" "$new" "$actargs" "$formargs"
90 local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5
91 desc $use "$base$ext" f$formargs a
92 alias_r $use ${base}${ext} f$actargs f$formargs
93 alias_r $use ${base}a${ext} f$actargs,0 f$formargs
94 alias_r $use ${base}b${ext} f$actargs,1 f$formargs
97 local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5
98 als_fa $use ${base}f "$ext" "$actargs" "$formargs"
99 alias_f $use ${base}w$ext $w$actargs,0 "$formargs" w
102 local use=$1 base=$2 ext=$3
103 als_fa $use ${base}f "$ext" ,1
104 als_fa $use ${base}w "$ext" ,0
107 local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5
108 als_fa $use ${base}f "$ext" $actargs,1 "$formargs"
109 als_fa $use ${base}fw "$ext" $actargs,0 "$formargs"
110 alias_f $use ${base}w$ext $w$actargs,0,0 "$formargs" w
114 alias_f $use ${base}_lw $lit $lit
116 als_k_lw_fda_2fw () {
118 als_fda_2fw ${base}wf ${base}_wf
119 als_k_lw ${base}lw ${base}
123 als_fa ${base}wf ${base}_wf
124 als_k_lw ${base}lw ${base}
128 local insn="$1" formargs=$2 notes=$3
129 desc "$insn" "$insn" "$formargs" "${notes}u"
132 local what=$1 flag=$2
133 ds="Branch if $what"; alias_f b$flag bra_$flag $lab $lab 8r
134 ds="Branch if Not $what"; alias_f bn$flag bra_n$flag $lab $lab 8r
137 if $macros; then echo ' ; autogenerated - do not edit'; echo ' nolist'; fi
139 # `literal operations' (DS282) that are also mirrored by
140 # `byte-oriented file register operations' (DS280)
141 ds='Add'; als_k_lw_fda_2fw add
142 ds='Bitwise AND'; als_k_lw_fda_2fw and
143 ds='Bitwise Inclusive OR'; als_k_lw_fda_2fw ior
144 ds='Bitwise Exclusive OR'; als_k_lw_fda_2fw xor
145 ds='Move (flags unchanged)'; als_k_lw_fa mov
146 ds='Multiply'; als_k_lw_fa mul
148 # `byte-oriented file register operations' (DS280)
149 ds='Add with carry'; als_fda_2fw addwfc addc_wf
150 ds='Clear'; als_fa_1fw clrf clr_
151 ds='Complement (bitwise NOT)'; als_fda_1fw comf com_
152 ds='Compare; if F!=W then...'; als_fa cpfseq cmp_fw _ifne
153 ds='Compare; if F<=W then...'; als_fa cpfsgt cmp_fw _ifle
154 ds='Compare; if F>=W then...'; als_fa cpfslt cmp_fw _ifge
155 ds='Decrement'; als_fda_1fw decf dec_
156 ds='Decrement; if !=0 then...'; als_fda_1fw decfsz dec_ _ifnz
157 ds='Decrement; if =0 then...'; als_fda_1fw dcfsnz dec_ _ifz
158 ds='Increment'; als_fda_1fw incf inc_
159 ds='Increment; if !=0 then...'; als_fda_1fw incfsz inc_ _ifnz
160 ds='Increment; if =0 then...'; als_fda_1fw infsnz inc_ _ifz
161 ds='Move'; als_fa movf mov_fw '' ,0
162 ds='Move F to same F'; als_fa movf mov_fsf '' ,1
163 ds='Move (flags unchanged)'; alias_f movff mov_ff f,g f,g
164 ds='Test'; alias_f movf tst_w $w,0,0 '' w
165 ds='Negate'; als_fa_1fw negf neg_
166 ds='Rotate left (through carry)'; als_fda_1fw rlcf rlc_
167 ds='Rotate left'; als_fda_1fw rlncf rl_
168 ds='Rotate right (through carry)'; als_fda_1fw rrcf rrc_
169 ds='Rotate right'; als_fda_1fw rrncf rr_
170 ds='Set all bits'; als_fa_1fw setf set_
171 ds='Subtract with borrow'; als_fda_2fw subfwb subb_fw
172 ds='Subtract with borrow'; als_fda_2fw subwfb subb_wf
173 ds='Subtract'; als_fda_2fw subwf sub_wf
174 ds='Swap nybbles'; als_fda_1fw swapf swap_
175 ds='Test; if !=0 then...'; als_fa_1fw tstfsz tst_ _ifnz
177 # `bit-oriented file register operations' (DS280)
178 ds='Bit Clear'; als_fa_1fw bcf bc_ '' ,b ,b
179 ds='Bit Set'; als_fa_1fw bsf bs_ '' ,b ,b
180 ds='Bit Toggle'; als_fa_1fw btg btg_ '' ,b ,b
181 ds='Bit Test; if 1 then...'; als_fa_1fw btfsc bt_ _if1 ,b ,b
182 ds='Bit Test; if 0 then...'; als_fa_1fw btfss bt_ _if0 ,b ,b
184 # `control operations' (DS281)
187 descs_bra Overflow ov
189 ds='Branch unconditionally'; noalias bra $lab 11r
190 ds='Call subroutine'; noalias call $lab 20
191 ds='Call subr., saving W,S,BSR'; alias_f call call_s $lab,1 $lab 20
192 ds='Clear watchdog timer'; noalias clrwdt
193 ds='Decimal adjust'; alias_f daw da_w
194 ds='Jump unconditionally'; noalias goto $lab 20
195 ds='No Operation'; noalias nop
196 ds='Pop top of return stack'; noalias pop
197 ds='Push PC+2 onto stack'; noalias push
198 ds='Branch to subroutine'; noalias rcall $lab 8r
199 ds='Reset the microcontroller'; noalias reset
200 ds="Return, reenabling Int's"; noalias retfie
201 ds="Return, ena.Int's, restoring W,S,BSR"; alias_f retfie retfie_r 1
202 ds='Return with literal in W'; noalias retlw $lit
203 ds='Return from subroutine'; noalias return
204 ds='Return, restoring W,S,BSR'; alias_f return return_r 1
205 ds='Go into standby mode'; noalias sleep
207 # `literal operations' (DS282)
208 ds='Subtract'; als_k_lw sublw sub
209 ds='Move literal to BSR' alias_f movlb mov_lb $lit $lit 4
210 ds='Move literal to FSR<i>' alias_f lfsr mov_lfsr i,$lit $lit,i 12,2
211 ds='Table Read' noalias tblrd */*+/*-/+*
212 ds='Table Write' noalias tblwt */*+/*-/+*
214 if $macros; then echo ' list'; fi
218 PIC18F458 INSTRUCTIONS AND PROVIDED OPCODE ALIASES sorted by OPCODE/ALIAS
220 Our opcode Args Notes Description Official
221 ------------- ------ ----- --------------------------------------- -------
224 PIC18F458 INSTRUCTIONS AND PROVIDED OPCODE ALIASES sorted by DESCRIPTION
226 Our opcode Args Notes Description Official
227 ------------- ------ ----- --------------------------------------- -------
230 PIC18F458 INSTRUCTIONS AND PROVIDED OPCODE ALIASES sorted by OFFICIAL INSN
232 Our opcode Args Notes Description Official
233 ------------- ------ ----- --------------------------------------- -------
236 ------------- ------ ---- --------------------------------------- -------
237 Notes: r Branch uses relative offset.
238 a Uses BSR for F iff F address is not in Access Bank. There are
239 also <op>_<how>a (always uses access bank) and <op>_<how>b
240 (always uses BSR). (<op>_<how>[ab]_if<what> for conditionals.)
241 u Official opcode, not an alias/macro. Listed for completeness.y
242 w Macro (alias) using WREG (the mapping of W in the Access Bank).
243 digits Gives number of bits of address or offset.
244 Z N C F Flags affected (out of C DC Z OV N). F: all of those affected.