Created
March 8, 2014 20:30
-
-
Save mshroyer/9438407 to your computer and use it in GitHub Desktop.
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
(destructuring-bind (offset in-path out-path) (cdr sb-ext:*posix-argv*) | |
(with-open-file (in in-path :element-type '(unsigned-byte 8)) | |
(with-open-file (out out-path :direction :output :if-exists :supersede) | |
(do ((c (make-array 32)) (n 0) (a (parse-integer offset :radix 16) (+ a n))) | |
((zerop (setq n (read-sequence c in)))) | |
(format out ":~2,'0X~4,'0X00" n a) | |
(format out "~2,'0X~%" (mod (- (apply #'+ a (ash a -8) n (map 'list (lambda (b) (format out "~2,'0X" b) b) (subseq c 0 n)))) 256))) | |
(format out ":00000001FF~%")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment