hexdump -v update.com -e "\"X10\" 16/1 \" \" \"\n\"" | grep -n \$ > update.lin
hexdump -v update.com -e "\"256 + %_ad\" 16/1 \" \" \"\n\"" | bc > update.adrd
for i in `cat update.adrd` ; { printf "%04.4X\n" $i ; } | grep -n \$ > update.adr
rm update.adrd
hexdump -v update.com -e "\"00\" 16/1 \"%2.2X\" \"\n\"" | grep -n \$ > update.dat
hexdump -v update.com -e "\"((1 + (255 - ((16 + ((256 + %_ad) MOD 256) + ((256 + %_ad) / 256) \" 16/1 \" + %u\" \") MOD 256) MOD 256) MOD 256) MOD 256)\n\"" | sed "s/MOD/%/g" - | bc > update.cksd
for i in `cat update.cksd` ; { printf "%02.2X\n" $i ; } | grep -n \$ > update.cks
rm update.cksd
join -t \: update.lin update.adr | join -t \: - update.dat | join -t \: - update.cks | cut -f 2- -d":" | sed "s/:/ /g" - | sed "s/ //g" - | sed "s/X/:/g" - > update.hes
rm update.lin update.adr update.dat update.cks
echo ":0000000000" >> update.hes
echo ":00000001FF" >> update.hes
for i in `cat update.hes` ; { echo -ne "$i\r" ; } > update.hex
rm update.hes
rm -f part*
split --bytes=2025 -a 2 -d update.hex part
for i in part* ; { echo -ne "\032" >> $i ; }
echo -ne "\032" >> update.hex

