Last active
March 18, 2018 14:56
-
-
Save kuninet/8e53d366c673fb7e43324cc902aa86b8 to your computer and use it in GitHub Desktop.
text hex dump file to Motorola S-record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# ダンプ形式テキストからモトローラSフォーマット生成 | |
# gawk 専用 | |
# - - - - | |
# HEXダンプファイルフォーマット | |
# アドレス データ2桁x16 | |
# ------- ------------------------- | |
# 0100 01 02 03 04 05 ... 16バイト分 | |
# | |
{ | |
chksum = 0 | |
hex = "0X13" | |
chksum += strtonum(hex) | |
hex = "0X" substr($1,1,2) | |
chksum += strtonum(hex) | |
hex = "0X" substr($1,3,2) | |
chksum += strtonum(hex) | |
# 16バイトづつ表示 | |
printf "S113" $1 | |
for (i=2;i<=17;i++){ | |
printf $i | |
hex = "0X" $i | |
chksum += strtonum(hex) | |
} | |
# チェックサム計算 | |
s_sum = sprintf("%X",chksum) | |
ss_sum = "0X" substr(s_sum,length(s_sum)-1,2) | |
sss_sum = sprintf("%X", compl(strtonum(ss_sum))) | |
printf substr(sss_sum,length(sss_sum)-1,2) | |
print "" | |
} | |
END{ | |
print "S9" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment