
my $FileName = $ARGV[0];
if($FileName eq ''){
	$FileName = "binout";
}

while(1){
	print ">";chomp(my $arg1 = <STDIN>);
	if($arg1 eq 'q'){
		last;
	}
	
	if($arg1 eq 'c'){
		unlink($FileName);
		print "Cleared\n";
		next;
	}
	my $tmp = "tmpfile" . rand();
	open(OUT, ">", $tmp) or die("$tmp open error");
	binmode(OUT);
	print OUT (&de(\$arg1));
	close(OUT);

	print `G:\\c\\os\\cd\\omake\\tolsrc\\aksa1a\\a.exe $tmp 0 0x7c00 0 30`;

	unlink($tmp);
}
sub de{
	my $data = shift;
	my $outdata = '';
	
	$data =~ s/0x[^ ]*://g;

	my @l = grep {length($_)!=0 && $_ ne ' '} split(//, $$data);
	for(my $i = 0; $i < scalar(@l); $i+=2){
		$outdata .= (chr(hex($l[$i].$l[$i+1])));
	}
	return $outdata;
}
