[][src]Function emulator::parse::read_program

pub fn read_program<R: Read>(reader: R) -> Result<[Instruction; 32]>

Parse 2i programs in string representation into arrays of Instructions.

Ignores empty lines and everything after the # char. You can use any char other than 0, 1 and : to format your program for improved readability.

Instructions can optionally be given an explicit address by prefixing them with the binary representation of the address followed by :. Instructions without an explicit address are saved at the next unused address. All addresses must be strictly nondecreasing. Missing instructions are replaced with self-looping instructions.

Examples

# Read value from FC into register 0

       00,00001 00 000|1100 01 01,1100 0
00001: 00,00000 01 000|0000 01 10,0001 0