sloc_purge

来自「A MP3 Player Source Code, Enjoy it!」· 代码 · 共 54 行

TXT
54
字号
#! /usr/bin/perl# remove the DSEG memory allocation for "sloc" variables# created by SDCC that were completely removed by the# custom peephole definitions in peephole.def.# first, read in all the asm codewhile (<>) {	chop;	$line[$lineno++] = $_;}for ($i=0; $i<$lineno; $i++) {	next unless $line[$i] =~ /^(_[A-Za-z0-9_]+sloc[0-9]+_[0-9]+_[0-9]+)::/;	$sloc = $1;	next unless $i < $lineno - 1;	next unless $line[$i+1] =~ /^[ \t]*\.ds[ \t]+([0-9]+)$/;	$sloc_alloc = $1;	#print "; $sloc\n";	$sloc_removable = 1;	$sloc_size = 1;	for ($j=$i+1; $j<$lineno; $j++) {		$_ = $line[$j];		$_ = $` if /;/;		if (/$sloc/) {			$sloc_removable = 0;			if (/\(${sloc} \+ ([0-9]+)\)/) {				$size = $1 + 1;				$sloc_size = $size if $size > $sloc_size;			}			#print "; $_\n";		}	}		if ($sloc_removable) {		#print "; purging $sloc\n";		$line[$i] = ';(sloc optimized away) ' . $line[$i];		$line[$i+1] = ';(sloc optimized away) ' . $line[$i+1];	} else {		if ($sloc_size < $sloc_alloc) {			$line[$i+1] = "\t.ds\t$sloc_size\t";			$line[$i+1] .= "; allocation changed to $sloc_size";			$line[$i+1] .= " (was $sloc_alloc)";		}	}}for ($i=0; $i<$lineno; $i++) {	print $line[$i], "\n";}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?