#! /bin/bash

# Prepare the headder part of the source code for SH2. 
cat > $2 <<_EOD_
	.CPU		SH2
	.SECTION	DSP,CODE
;==========================================================================
	.EXPORT	BlackfinBytes
	.ALIGN	4
BlackfinBytes:
	.DATA.L	BlackfinEnd-BlackfinStart
BlackfinStart:
    .DATA.B H'00,H'00,H'80,H'ff,H'04,H'00,H'00,H'00,H'32,H'00,H'DE,H'AD,H'BE,H'EF
_EOD_

# convert the Blackfin LDR file as first parameter to the SH2 Assembler data format.
od  -v -t x1 $1 | sed "s/ /\,/g" |sed "s/^[0-9]*\,/.DATA.B ,/" | sed "s/,/,H\'/g" | sed "/^[0-9]*$/d" | sed "s/[0-9a-f]H//" | sed "s/,//" | sed "s/^/\t/" >> $2

# Add the tail part to the source code for SH2.
cat >>$2 <<_EOD_
BlackfinEnd:
	.END
_EOD_