Subversion Repositories Spectranet

[/] [trunk/] [z88dk/] [scripts/] [makesources.pl] - Blame information for rev 499

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 146 winston
#!/usr/bin/perl
2
use strict;
3
 
4
opendir(DHND, ".") or die("Could not opendir: $!");
5
 
6
while(my $dirent=readdir(DHND))
7
{
8
        if($dirent =~ /\.asm/)
9
        {
10
                processfile($dirent);
11
        }
12
}
13
 
14
sub processfile
15
{
16
        my $dirent=shift;
17
        my $nopaged=$dirent;
18
        my $paged=$dirent;
19
        $nopaged=~s/\.asm/_np\.asm/g;
20
        $paged=~s/\.asm/_p\.asm/g;
21
 
22
        open FHND, "< $dirent" or die("Could not open $dirent: $!");
23
        my $line=<FHND>;
24
        if($line =~ /^; process/i)
25
        {
26
                open PHND, "> $paged"
27
                        or die("Could not open $paged: $!");
28
                open NHND, "> $nopaged"
29
                        or die("Could not open $nopaged: $!");
30
 
31
                my $msg="; do not edit this file, it has been automatically generated.\n";
32
                print PHND $msg;
33
                print NHND $msg;
34
 
35
                while(my $line=<FHND>)
36
                {
37
                        if($line =~ /HLCALL/ || $line =~ /IXCALL/)
38
                        {
39
                                $line=~s/^\s|\s$|\r|\n//g;
40
                                my ($op, $param)=split(/\s{1,}/, $line);
41
                                print PHND "    ld " . substr($op, 0, 2) .", $param\n";
42
                                print PHND "    call $op\n";
43
                                print NHND "    call $param\n";
44
                        }
45
                        else
46
                        {
47
                                print PHND $line;
48
                                print NHND $line;
49
                        }
50
                }
51
                close(PHND);
52
                close(NHND);
53
        }
54
        close(FHND);
55
}
56
 
57
closedir(DHND);
58