From 792ff96588d02c05b5e809f8840cc821e51dedf9 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 24 Apr 2005 13:31:06 +0000 Subject: [PATCH] reorgansed, bugfixed, improved --- iwjpictest/Makefile | 15 ++++--- iwjpictest/insn-aliases.inc-gen | 74 +++++++++++++++++++-------------- iwjpictest/insn-makecheck | 5 +++ 3 files changed, 54 insertions(+), 40 deletions(-) create mode 100755 iwjpictest/insn-makecheck diff --git a/iwjpictest/Makefile b/iwjpictest/Makefile index 2e084d0..07a608d 100644 --- a/iwjpictest/Makefile +++ b/iwjpictest/Makefile @@ -1,8 +1,8 @@ TARGETS= config.hex $(INSN_TARGETS) INSN_TARGETS= insn-aliases.inc \ - insn-1.txt insn-2.txt \ - insn-1.ps insn-2.ps + insn-opcode.txt insn-desc.txt insn-check.txt \ + insn-opcode.ps insn-desc.ps PROGRAMS= flasher copybits serialloop @@ -15,12 +15,11 @@ clean: pic-clean insn-aliases.inc: insn-aliases.inc-gen ./$< --macros $o -insn-%.txt: insn-aliases.inc-gen Makefile - sed -e '1,/^#--$*--/d; /^#--0--/,$$d' <$< >$@.1.tmp - ./$< --descs >$@.2.tmp - sort -t % -k 1.$(subst 2,28,$*) <$@.2.tmp >>$@.1.tmp - sed -e '1,/^#--3--/d; /^#--0--/,$$d' <$< >>$@.1.tmp - mv -f $@.1.tmp $@ +insn-%.txt: insn-aliases.inc-gen + ./$< --by-$* $o + +insn-check.txt: insn-makecheck insn-aliases.inc + ./$^ $o insn-%.ps: insn-%.txt atp -T A4 -B -f Courier7.8 <$< $o diff --git a/iwjpictest/insn-aliases.inc-gen b/iwjpictest/insn-aliases.inc-gen index ee6faef..65dd1c6 100755 --- a/iwjpictest/insn-aliases.inc-gen +++ b/iwjpictest/insn-aliases.inc-gen @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e badusage () { echo >&2 'bad usage'; exit 1; } @@ -7,20 +7,31 @@ comment=';' macros=false case "$1" in ---macros) macros=true ;; ---descs) comment='' ;; -*) badusage ;; +--by-opcode) cohere=$1; sortkey=1 ;; +--by-desc) cohere=$1; sortkey=29 ;; +--macros) macros=true ;; +--descs) comment='' ;; +*) badusage ;; esac test $# = 1 || badusage +if [ x$cohere != x ]; then + sed <$0 -e '1,/^#'$cohere'--/d; /^#--0--/,$d' + "$0" --descs | sort -t % -k 1.$sortkey + test "${PIPESTATUS[*]}" = "0 0" + sed <$0 -e '1,/^#--3--/d; /^#--0--/,$d' + exit 0 +fi + w=0xfe8 lab=n +lit=k desc () { local use=$1 new=$2 formargs=$3 notes=$4 local fan="$(printf "%-6s %s" "$formargs" "$notes")" if $descs; then - printf "$comment %-13s %-11s %-39s %s\n" \ + printf "$comment %-13s %-12s %-39s %s\n" \ "$new" "$fan" "$ds" "$use" fi } @@ -42,7 +53,7 @@ alias_f () { } als_fa () { local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5 - desc $use "$base$ext" f$formargs A + desc $use "$base$ext" f$formargs a alias_r $use ${base}${ext} f$actargs f$formargs alias_r $use ${base}a${ext} f$actargs,0 f$formargs alias_r $use ${base}b${ext} f$actargs,1 f$formargs @@ -50,7 +61,7 @@ als_fa () { als_fa_1fw () { local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5 als_fa $use ${base}f "$ext" "$actargs" "$formargs" - alias_f $use ${base}w$ext $w$actargs,0 "$formargs" + alias_f $use ${base}w$ext $w$actargs,0 "$formargs" w } als_fda_2fw () { local use=$1 base=$2 ext=$3 @@ -61,11 +72,11 @@ als_fda_1fw () { local use=$1 base=$2 ext=$3 actargs=$4 formargs=$5 als_fa $use ${base}f "$ext" $actargs,1 "$formargs" als_fa $use ${base}fw "$ext" $actargs,0 "$formargs" - alias_f $use ${base}w$ext $w$actargs,0,0 "$formargs" + alias_f $use ${base}w$ext $w$actargs,0,0 "$formargs" w } als_k_lw () { local use=$1 base=$2 - alias_f $use ${base}_lw l l + alias_f $use ${base}_lw $lit $lit } als_k_lw_fda_2fw () { local base=$1 @@ -79,13 +90,13 @@ als_k_lw_fa () { } noalias () { - local insn="$1"; shift - desc "$insn" "$insn" "$@" + local insn="$1" formargs=$2 notes=$3 + desc "$insn" "$insn" "$formargs" "${notes}u" } descs_bra () { local what=$1 flag=$2 - ds="Branch if $what"; alias_f b$flag bra_$flag $lab $lab 8R - ds="Branch if Not $what"; alias_f bn$flag bra_n$flag $lab $lab 8R + ds="Branch if $what"; alias_f b$flag bra_$flag $lab $lab 8r + ds="Branch if Not $what"; alias_f bn$flag bra_n$flag $lab $lab 8r } if $macros; then echo ' ; autogenerated - do not edit'; fi @@ -123,7 +134,7 @@ ds='Rotate right'; als_fda_1fw rrncf rr_ ds='Set all bits'; als_fa_1fw setf set_ ds='Subtract with borrow'; als_fda_2fw subfwb subb_fw ds='Subtract with borrow'; als_fda_2fw subwfb subb_wf -ds='Subtract'; als_fda_2fw subfw sub_fw +ds='Subtract'; als_fda_2fw subwf sub_wf ds='Swap nybbles'; als_fda_1fw swapf swap_ ds='Test; if !=0 then...'; als_fa_1fw tstfsz tst_ _ifnz @@ -138,7 +149,7 @@ descs_bra Carry c descs_bra Negative n descs_bra Overflow ov descs_bra Zero z -ds='Branch unconditionally'; noalias bra $lab 11R +ds='Branch unconditionally'; noalias bra $lab 11r ds='Call subroutine'; noalias call $lab 20 ds='Call subr., saving W,S,BSR'; alias_f call call_s $lab,1 $lab 20 ds='Clear watchdog timer'; noalias clrwdt @@ -147,43 +158,42 @@ ds='Jump unconditionally'; noalias goto $lab 20 ds='No Operation'; noalias nop ds='Pop top of return stack'; noalias pop ds='Push PC+2 onto stack'; noalias push -ds='Branch to subroutine'; noalias rcall $lab 8R +ds='Branch to subroutine'; noalias rcall $lab 8r ds='Reset the microcontroller'; noalias reset ds="Return, reenabling Int's"; noalias retfie ds="Return, ena.Int's, restoring W,S,BSR"; alias_f retfie retfie_r 1 -ds='Return with literal in W'; noalias retlw +ds='Return with literal in W'; noalias retlw $lit ds='Return from subroutine'; noalias return ds='Return, restoring W,S,BSR'; alias_f return return_r 1 ds='Go into standby mode'; noalias sleep # `literal operations' (DS282) -ds='Subtract'; als_k_lw sublw sub -ds='Move literal to BSR' alias_f movlb mov_lb l 4 -ds='Move literal to FSR' alias_f lfsr mov_lfsr i,l i,l 2,12 -ds='Table Read' noalias tblrd */*+/*-/+* -ds='Table Write' noalias tblwt */*+/*-/+* +ds='Subtract'; als_k_lw sublw sub +ds='Move literal to BSR' alias_f movlb mov_lb $lit $lit 4 +ds='Move literal to FSR' alias_f lfsr mov_lfsr i,$lit $lit,i 12,2 +ds='Table Read' noalias tblrd */*+/*-/+* +ds='Table Write' noalias tblwt */*+/*-/+* if $macros; then echo ' ; the end'; fi exit 0 -#--1-- +#--by-opcode-- PIC18F458 INSTRUCTIONS AND PROVIDED OPCODE ALIASES sorted by OPCODE/ALIAS - -Our opcode Args Notes Description Official - ------------- ------ ---- --------------------------------------- ------- + Our opcode Args Notes Description Official + ------------- ------ ----- --------------------------------------- ------- #--0-- -#--2-- +#--by-desc-- PIC18F458 INSTRUCTIONS AND PROVIDED OPCODE ALIASES sorted by DESCRIPTION - -Our opcode Args Notes Description Official - ------------- ------ ---- --------------------------------------- ------- + Our opcode Args Notes Description Official + ------------- ------ ----- --------------------------------------- ------- #--0-- #--3-- ------------- ------ ---- --------------------------------------- ------- -Notes: R Branch uses relative offset. - A Uses BSR for F iff F address is not in Access Bank. There are +Notes: r Branch uses relative offset. + a Uses BSR for F iff F address is not in Access Bank. There are also _a (always uses access bank) and _b (always uses BSR). (_[ab]_if for conditionals.) + u Official opcode, not an alias/macro. Listed for completeness. digits Gives number of bits of address or offset. $Id$ #--0-- diff --git a/iwjpictest/insn-makecheck b/iwjpictest/insn-makecheck new file mode 100755 index 0000000..2ea73d0 --- /dev/null +++ b/iwjpictest/insn-makecheck @@ -0,0 +1,5 @@ +#!/usr/bin/perl -p +s/^\; (\w+)\s+(\S*)\s+\S*u\s.*$/ sprintf "%-15s %-7s \t%s\t%s", $1,$2,$1,$2 /e; +s/^\s*\;.*\n//; +s/^(\w+)\s+macro\s+(.*)\n/ sprintf "%-15s %-7s ", $1, $2 /e; +s/^\s+endm\n$//; -- 2.30.2