| 1 | package VM::Dreamer::Languages::Grasshopper; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = '0.851'; | ||
| 7 | |||
| 8 | use VM::Dreamer::Instructions qw( input_to_mb output_from_mb store load add subtract branch_always branch_if_zero branch_if_positive halt ); | ||
| 9 | |||
| 10 | require Exporter; | ||
| 11 | |||
| 12 | our @ISA = qw(Exporter); | ||
| 13 | our @EXPORT_OK = qw( get_instruction_set ); | ||
| 14 | |||
| 15 | my %instruction_set = ( | ||
| 16 | 1 => \&input_to_mb, | ||
| 17 | 2 => \&output_from_mb, | ||
| 18 | 3 => \&store, | ||
| 19 | 4 => \&load, | ||
| 20 | 5 => \&add, | ||
| 21 | 6 => \&subtract, | ||
| 22 | 7 => \&branch_always, | ||
| 23 | 8 => \&branch_if_zero, | ||
| 24 | 9 => \&branch_if_positive, | ||
| 25 | 0 => \&halt | ||
| 26 | ); | ||
| 27 | |||
| 28 | sub get_instruction_set { | ||
| 29 | return \%instruction_set; | ||
| 30 | } | ||
| 31 | |||
| 32 | # MDL - Machine Definition Language - 1.0 | ||
| 33 | |||
| 34 | # name:Grasshopper | ||
| 35 | # base:10 | ||
| 36 | # op_code_width:1 | ||
| 37 | # operand_width:2 | ||
| 38 | # language:Grasshopper | ||
| 39 | |||
| 40 | # validate_definition(%definition); | ||
| 41 | |||
| 42 | # - all required keys are present | ||
| 43 | # - no keys which not expected | ||
| 44 | # - all values are of proper form relative to key they define | ||
| 45 | |||
| 46 | # - name is lte 32 characters | ||
| 47 | # starts with a letter | ||
| 48 | # contains only letters, numbers or underscores | ||
| 49 | |||
| 50 | # - language is lte 32 characters | ||
| 51 | # starts with a capital letter | ||
| 52 | # contains only letters, numbers or underscores | ||
| 53 | |||
| 54 | 1; | ||
| 55 | |||
| 56 | =pod | ||
| 57 | |||
| 58 | =head1 AUTHOR | ||
| 59 | |||
| 60 | William Stevenson <dreamer at coders dot coop> | ||
| 61 | |||
| 62 | =head1 COPYRIGHT AND LICENSE | ||
| 63 | |||
| 64 | This software is Copyright (c) 2013 by William Stevenson. | ||
| 65 | |||
| 66 | This is free software, licensed under: | ||
| 67 | |||
| 68 | The Artistic License 2.0 (GPL Compatible) | ||
| 69 | |||
| 70 | =cut |