VM::Dreamer::IO - IO functionality for Dreamer
get_valid_input_from_user($machine) add_input_to_inbox( $machine, $input ) shift_inbox_to_memory( $machine, $address ) add_to_outbox( $machine, $operand ) shift_outbox_to_user($machine)
This module handles IO functions for Dreamer. This just means that it can:
Prompts the user for input. Valid input is returned otherwise the user is told what they did wrong and asked to try again. Raises an exception if max_tries is exceeded by the user.
Note: The user doesn't need to zero-pad their input. They can do so if they like, but the input can't have more digits than the largest number they can enter.
I.e. if the largest number they can enter is 999, 15 and 015 are acceptable, but 0015 would be rejected.
Pushes input to the "top" of the Inbox.
Shifts the "bottom" of the inbox to an address in memory.
Adds the information stored at an address in memory to the "top" of the Outbox.
Putputs the value at the "bottom" of the Outbox to the user. Note all output is zero-padded to have the same number of digits as the "width" of each address in memory.
This means that if your memory is 8 digits wide and each digit can be between 0 and 7, the number 715 would be output as 00000715.
This may change in a future release.
Together, the first three methods are used to implement VM::Dreamer::Instructions::input_to_mb and the last two are used to implemtn VM::Dreamer::Instructions::output_from_mb. These in turn are the INP and OUT operations for Grasshopper.
I've tried to follow the FIFO concept of First In, First Out; however, I don't know how well I understand the underlying concepts. If you know better and see any conceptual issues with the implementation, please let me know.
William Stevenson <william at coders dot coop>
VM::Dreamer::Instructions
This software is Copyright (c) 2013 by William Stevenson.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install VM::Dreamer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VM::Dreamer
CPAN shell
perl -MCPAN -e shell install VM::Dreamer
For more information on module installation, please visit the detailed CPAN module installation guide.