1 # Postprocessor for dsp56k bootstrap code.
3 # Copyright Ben Hutchings 2011.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
16 # Reconstruct memory image and symbol table
18 if (/^P ([0-9A-F]{4}) ([0-9A-F]{6})\n/) {
19 $memory[hex($1)] = hex($2);
20 } elsif (/^I ([0-9A-F]{6}) (\w+)\n/) {
21 $symbol{$2} = hex($1);
23 print STDERR "W: did not recognise line $.\n";
27 # Concatenate first and second stage. Second stage is assembled
28 # between 'upload' and 'upload_end', but initially loaded at
29 # 'real' (end of the first stage).
30 for (0 .. ($symbol{real} - 1), $symbol{upload} .. ($symbol{upload_end} - 1)) {
31 my $word = $memory[$_] || 0;
32 print pack('CCC', $word / 65536, ($word / 256) % 256, $word % 256);