package uk.co.transputersystems.open_transputer.rom;

import java.io.File;

public class RomBuilder {
    public static void run(File input, File output) {
        System.out.println("Hello world.");
    }
}

@@ -62,20 +62,94 @@
 java.io.
-File
+*;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport java.util.Scanner
 ;%0A%0Apubli
@@ -225,51 +225,1932 @@
 ut) 
-%7B%0A        System.out.println(%22Hello world.%22
+throws Exception %7B%0A%0A        FileReader inputStream = new FileReader(input);%0A        Scanner inputScanner = new Scanner(inputStream);%0A%0A        // Skip over 'Start address: XXXXXXXX'%0A        inputScanner.nextLine();%0A%0A        // Parse input%0A        List%3CInteger%3E values = new ArrayList%3C%3E();%0A        Integer currentVal = 0;%0A        int bCount = 0;%0A        while (inputScanner.hasNextInt(16)) %7B%0A            currentVal = currentVal %7C ((inputScanner.nextInt(16) %3C%3C (8 * bCount)) & (0xFF %3C%3C (8 * bCount)));%0A            bCount++;%0A%0A            if (bCount == 4) %7B%0A                values.add(currentVal);%0A                bCount = 0;%0A                currentVal = 0;%0A            %7D%0A        %7D%0A        if (bCount != 0) %7B%0A            values.add(currentVal);%0A        %7D%0A%0A        if (values.size() %3E (2592 - 1297 - 2 - 9)) %7B%0A            throw new OutOfMemoryError(%22Program is too big!%22);%0A        %7D%0A%0A        // Generate output%0A%0A        FileWriter wr = new FileWriter(output);%0A        PrintWriter printer = new PrintWriter(wr);%0A%0A        // Header%0A        /*%0A         * memory_initialization_radix=16;%0A         * memory_initialization_vector=%0A         */%0A        printer.println(%22memory_initialization_radix=16;%22);%0A        printer.println(%22memory_initialization_vector=%22);%0A%0A        // 9 lines of 00000000%0A        for (int i = 0; i %3C 9; i++) %7B%0A            printer.println(%2200000000,%22);%0A        %7D%0A%0A        // 2 lines of 80000000%0A        for (int i = 0; i %3C 2; i++) %7B%0A            printer.println(%2280000000,%22);%0A        %7D%0A%0A        // 1,297 lines of 00000000%0A        for (int i = 0; i %3C 1297; i++) %7B%0A            printer.println(%2200000000,%22);%0A        %7D%0A%0A        // Program code padded out to 2592 lines%0A        for (int i = 0; i %3C values.size(); i++) %7B%0A            printer.printf(%22%2508x,%5Cn%22, values.get(i));%0A        %7D%0A        for (int i = values.size() + 1297 + 2 + 9; i %3C 2592; i++) %7B%0A            printer.println(%2200000000,%22);%0A        %7D%0A%0A        wr.close(
 );%0A 

Implement Bin2ROM tool