Last active
December 1, 2018 13:43
-
-
Save reidrac/ea7a5caf5e98d62e7868849980c91f57 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
#!/bin/bash | |
# | |
# Check SDCC map files and calculate how much RAM you have left | |
# | |
# max_mem is top mem minus your code start, for example: 41179 | |
# | |
set -e | |
if [ $# -ne 2 ]; then | |
echo "$0 max_mem filename.map" | |
exit 1 | |
fi | |
CURRENT=`egrep -u "^_" < $2 | sort -u | awk ' BEGIN { t=0 } /^_/ && /bytes/ { t = t + strtonum($5) } END { print t }'` | |
LEFT=$(($1 - $CURRENT)) | |
cat <<ENDL | |
*** | |
Max: $1 bytes | |
Current: $CURRENT bytes ($2) | |
Left: $LEFT bytes | |
*** | |
ENDL | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment