I did look at AVR stuff last night but they dodn't offer much over the
PIC that we currently use heavilly in our controller designs. - did I
miss something?
I only ever write assembler - control freak that I am

)
Quite right too - for the tiny devices with e.g. a stack dept of 8, I
don't see how any HLL could be made to work properly.
You might be into this already? But a good plan is to build up a
libraries of routines as macros. Then you can declare them in *any*
order at the start (forward references are allowed - because they are
not compiled).
Then insert them, as required, in your main code.
E.g.
; start of file called e.g. macro_library
;************************************************************************
; bulk left rotate
* *
;********************
*
; Rotate 65 bits of table + C to the
left. *
; The carry enters the lsb of
table[0]. *
; table[7] outputs its msb into the
carry. *
;
*
; Entry: M......L <--C table[0] prepare C for lr into lsb of
table[0] *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
; M......L
table[7] *
;
*
; Exit ......LC
table[0] *
; ......LM
*
; ......LM
*
; ......LM
*
; ......LM
*
; ......LM
*
; ......LM
*
; C <-- ......LM table[7] C now contains old msb of
table[7] *
;************************************************************************
blk_lr_tbl macro s ;bulk left rotate 8 bytes, one bit
bnk_tbl_st s ;init FSR to start of table
blk_lr_tbl_10
rlf INDF,f
incf FSR,f
skif_b3_changes s
goto blk_lr_tbl_10
return
endm
bnk_tbl_st macro s ;point FSR at table start
movlw s
movwf FSR
endm
;************************************************************************
; bulk right rotate, carry copied into msb
* *
;*******************************************
*
; Rotate 64 bits of table
right. *
; The lsb of table[0] enters the msb of
table[7]. *
; table[0] outputs its lsb into the
carry. *
;
*
; Entry: M......X
table[0] *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
; M......L
table[7] *
;
*
; Exit LM...... -->C table[0] C ==
X *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
; XM......
table[7] *
;************************************************************************
blk_rr_tbl_pure macro s ;bulk right rotate 64 bits, one bit
bk_rr_tbl s
bsf (s + D'7'),7 ;
btfss STATUS,stat_C_bit ;
bcf (s + D'7'),7 ;
return
endm
;************************************************************************
; bulk right rotate
* *
;********************
*
; Rotate 65 bits of table + C
right. *
; The carry enters the msb of
table[7]. *
; table[0] outputs its lsb into the
carry. *
;
*
; Entry: M......X
table[0] *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
;
M......L *
; C--> M......L table[7] prepare C for rr into msb of
table[7] *
;
*
; Exit LM...... -->C table[0] C contains lsb that was in
table[0] *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
;
LM...... *
; CM......
table[7] *
;************************************************************************
blk_rr_tbl macro s ;bulk right rotate 65 bits, one bit
bk_rr_tbl s
; return
endm
bk_rr_tbl macro s
local bk_rr_tbl_10
bnk_tbl_end s
bk_rr_tbl_10
rrf INDF,f ;rotate C into msb-end from highest
byte
decf FSR,f ;move down the table
skif_b3_changes s
goto bk_rr_tbl_10
endm
bnk_tbl_end macro s ;point FSR at table end
movlw (s + D'7')
movwf FSR
endm
;************************************************************************
; End of bulk right
rotate *
;************************************************************************
;************************************************************************
; compare table macro
* *
;**********************
*
; Compare one eight byte table with another 8 byte table. The
tables *
; must lie on "MOD 8 boundaries" e.g. 0x40 or
0x48 *
;
*
; Conditional assembly to ensure that the correct bxf and
btfsx *
; instructions match the table's
locations. *
;
*
; Form:
comp_tab(table[8],table[8]) *
;
*
; Entry: bank_x == don't
care *
; table == ((any_address MOD 8) ==
0) *
;
*
; Exit: (table_x == table_y) ? Z == true : Z ==
false *
; bank_x ==
unaltered *
;************************************************************************
Compare_data macro s,d ;Compares 8 bytes of bank1 upper to
lower
local compare_data_10
local compare_data_20
bnk_tbl_st s
compare_data_10
set_fsr_source
movf INDF,w ;get source
set_fsr_dest
subwf INDF,w ;compare
btfss STATUS,stat_Z_bit ;skif zero
goto compare_data_20 ;Exit, compare failed with Z=0
incf FSR,f
skif_b3_changes d
goto compare_data_10 ;
clrw ;set Z
compare_data_20
return
endm
;************************************************************************
; End of copare
tables *
;************************************************************************
;************************************************************************
; copy table
* *
;*************
*
; Copy one eight byte table to another 8 byte table. The tables must
lie*
; on "MOD 8 boundaries" e.g. 0x40 or
0x48 *
;
*
; Conditional assembly to ensure that the correct bxf and
btfsx *
; instructions match the table's
locations. *
;
*
; Form: copy_tab(source,
destination) *
;
*
; Entry: bank_x == don't
care *
; source == ((any_address MOD 8) ==
0) *
; destination == ((any_address MOD 8) ==
0) *
;
*
; Exit: destination[7,0] ==
source[7,0] *
; bank_x ==
unaltered *
;************************************************************************
copy_tab macro s,d
local copy_tab_10
bnk_tbl_st s
copy_tab_10
set_fsr_source
movf INDF,w ;get source
set_fsr_dest
movwf INDF ;put destination
incf FSR,f
skif_b3_changes d
goto copy_tab_10
; return
endm
;************************************************************************
; End of copy_tab
macro *
;************************************************************************
;************************************************************************
; clear table
* *
;**************
*
; Clear eight byte table. The tables must lie on "MOD 8
boundaries" *
; e.g. 0x40 or
0x48 *
;
*
; Conditional assembly to ensure that the correct bxf and
btfsx *
; instructions match the table's
locations. *
;
*
; Form:
clr_tab(source) *
;
*
; Entry: bank_x == don't
care *
; source == ((any_address MOD 8) ==
0) *
;
*
; Exit: source[7,0] ==
0 *
; bank_x ==
unaltered *
;************************************************************************
clr_tab macro s
local clr_tab_10
bnk_tbl_st s
clr_tab_10
clrf INDF
incf FSR,f
skif_b3_changes s
goto clr_tab_10
return
endm
;************************************************************************
; End of clr_tab
macro *
;************************************************************************
set_fsr_source macro
if((d & H'40') < (s & H'40')) ;
bsf FSR,6 ;
endif ;
if((d & H'20') < (s & H'20')) ;
bsf FSR,5 ;
endif ;
if((d & H'10') < (s & H'10')) ;
bsf FSR,4 ;
endif ;
if((d & H'08') < (s & H'08')) ;
bsf FSR,3 ;
endif ;
if((d & H'40') > (s & H'40')) ;
bcf FSR,6 ;
endif ;
if((d & H'20') > (s & H'20')) ;
bcf FSR,5 ;
endif ;
if((d & H'10') > (s & H'10')) ;
bcf FSR,4 ;
endif ;
if((d & H'08') > (s & H'08')) ;
bcf FSR,3 ;
endif ;
endm
set_fsr_dest macro
if((d & H'40') < (s & H'40')) ;
bcf FSR,6 ;
endif ;
if((d & H'20') < (s & H'20')) ;
bcf FSR,5 ;
endif ;
if((d & H'10') < (s & H'10')) ;
bcf FSR,4 ;
endif ;
if((d & H'08') < (s & H'08')) ;
bcf FSR,3 ;
endif ;
if((d & H'40') > (s & H'40')) ;
bsf FSR,6 ;
endif ;
if((d & H'20') > (s & H'20')) ;
bsf FSR,5 ;
endif ;
if((d & H'10') > (s & H'10')) ;
bsf FSR,4 ;
endif ;
if((d & H'08') > (s & H'08')) ;
bsf FSR,3 ;
endif ;
endm
skif_b3_changes macro t ;Insert apt btfsx instruction to suit
parameter
if(D'8' & t) ;
btfsc FSR,3 ;if(bit 3) then insert this
else ;
btfss FSR,3 ;if(!bit 3) then insert this
endif
endm
;************************************************************************
; jumper: goto(here + offset_in_W)
* *
;***********************************
*
; Computed goto (see
AN556). *
;
*
; Expects: W ==
offset *
; jumptable == concatenated to this
macro *
;
*
; Uses:
temp *
;************************************************************************
jumper macro
local jumper_10
local jumptable
movwf temp
movlw LOW jumper_10
addwf temp,w
movlw HIGH jumper_10
btfsc STATUS,stat_C_bit
addlw D'1'
movwf PCLATH
movf temp,w
jumper_10
addwf PCL,f
jumptable ; jump table starts here.
endm
;************************************************************************
; End of
jumper *
;************************************************************************
;************************************************************************
; End of macro
library *
;************************************************************************
; end of file called e.g. macro_library
Cheers
Robin