File:  [HATARI the Atari ST Emulator] / hatari / src / uae-cpu / add_cycles.pl
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Mon Apr 1 07:13:47 2019 UTC (7 years, 3 months ago) by root
Branches: hatari, MAIN
CVS tags: hatari01000, HEAD
hatari 1.0.0

#!/usr/bin/perl -w
#
# Simple script used to parse cpuemu.c and to generate
# a new cpuemu.c where each opcode sets CurrentInstrCycles
# to the value that would be returned at the end of this
# opcode's processing.
#
# This allows to know how many cycles an instructions will take
# while handling its memory accesses (this is needed for
# accurate border removal emulation).
#
# This script is not perfect (doesn't give correct cycles
# values for variable cycles intr. like rol, lsl, movem, ...)
# but it is enough for border removal as instruction are
# often move or clr with fixed cycles count.
#
# 2007/03/07	[NP]	OK



$in_func = 0;

while ( <> )
  {
    $line = $_;

    # not in a function, we print back to stdout
    if ( $in_func == 0 )
      {
        print $line;
        $in_func = 1 if $line =~ /^{/;
      }

    # we're entering in a function ; we buffer everything
    # until we reach the 'return' line, then we print
    # the CurrentInstrCycles based on the numeric value in
    # the 'return' line, finally we print the buffered lines.
    else
      {
	push @buf , $line;		# create a buffer for the function's body

	if ( $line =~ /return \(?(\d+)/ )
	  {
	    print "CurrentInstrCycles = $1;\n";
	    print @buf;
	    @buf = ();
	    $in_func = 0;
	  }
      }
  }


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.