Canola  0.8.D001
lib/calculator/on_opcode_lrn.cc
Go to the documentation of this file.
00001 //
00002 // canola - canon canola 1614p emulator
00003 // Copyright (C) 2011, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, version 3, as
00007 // published by the Free Software Foundation.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program. If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include <lib/ac/string.h>
00019 
00020 #include <lib/calculator.h>
00021 
00022 
00023 void
00024 calculator::on_opcode_lrn(opcode_t op, const location::pointer &where)
00025 {
00026     assert(address <= 240);
00027     switch (op)
00028     {
00029     case opcode_zero:
00030         goto yuck;
00031 
00032     case opcode_plus_equals:
00033     case opcode_minus_equals:
00034     case opcode_mul:
00035     case opcode_div:
00036     case opcode_sqrt:
00037     case opcode_ent:
00038     case opcode_sj:
00039     case opcode_ej:
00040     case opcode_mj:
00041     case opcode_uj:
00042     case opcode_fj:
00043     case opcode_suj:
00044     case opcode_sfj:
00045     case opcode_srj:
00046     case opcode_m1:
00047     case opcode_m2:
00048     case opcode_m3:
00049     case opcode_m4:
00050     case opcode_m5:
00051     case opcode_m6:
00052     case opcode_m7:
00053     case opcode_m8:
00054     case opcode_m9:
00055     case opcode_m10:
00056     case opcode_m11:
00057     case opcode_m12:
00058     case opcode_m13:
00059     case opcode_m14:
00060     case opcode_mm1:
00061     case opcode_mm2:
00062     case opcode_sm3:
00063     case opcode_sm4:
00064     case opcode_sm5:
00065     case opcode_sm6:
00066     case opcode_sm7:
00067     case opcode_sm8:
00068     case opcode_sm9:
00069     case opcode_sm10:
00070     case opcode_sm11:
00071     case opcode_sm12:
00072     case opcode_sm13:
00073     case opcode_sm14:
00074     case opcode_rm1:
00075     case opcode_rm2:
00076     case opcode_rm3:
00077     case opcode_rm4:
00078     case opcode_rm5:
00079     case opcode_rm6:
00080     case opcode_rm7:
00081     case opcode_rm8:
00082     case opcode_rm9:
00083     case opcode_rm10:
00084     case opcode_rm11:
00085     case opcode_rm12:
00086     case opcode_rm13:
00087     case opcode_rm14:
00088     case opcode_clear_indicator:
00089     case opcode_cm1:
00090     case opcode_cm2:
00091     case opcode_cm3:
00092     case opcode_cm4:
00093     case opcode_cm5:
00094     case opcode_cm6:
00095     case opcode_cm7:
00096     case opcode_cm8:
00097     case opcode_cm9:
00098     case opcode_cm10:
00099     case opcode_cm11:
00100     case opcode_cm12:
00101     case opcode_cm13:
00102     case opcode_cm14:
00103     case opcode_dot:
00104     case opcode_rv:
00105     case opcode_right:
00106     case opcode_chg_sign:
00107     case opcode_round_down:
00108     case opcode_round_off:
00109     case opcode_round_up:
00110     case opcode_print:
00111     case opcode_fd:
00112     case opcode_n0:
00113     case opcode_n1:
00114     case opcode_n2:
00115     case opcode_n3:
00116     case opcode_n4:
00117     case opcode_n5:
00118     case opcode_n6:
00119     case opcode_n7:
00120     case opcode_n8:
00121     case opcode_n9:
00122     case opcode_n10:
00123     case opcode_n11:
00124     case opcode_n12:
00125     case opcode_n13:
00126     case opcode_n14:
00127         binary:
00128         address = wrap_address(address + 1);
00129         programme[address] = op;
00130         programme_location[address] = where;
00131         return;
00132 
00133     case opcode_extended_c:
00134         {
00135             clock_tick_mode = clock_tick_mode_disabled;
00136             clear_program();
00137         }
00138         return;
00139 
00140     case opcode_extended_start:
00141         on_error
00142         (
00143             "The START key is ignored in LRN mode.  If you want to edit "
00144             "your program, use PRO CHE mode instead."
00145         );
00146         break;
00147 
00148     case opcode_extended_m3_tilde:
00149     case opcode_extended_sm3_tilde:
00150     case opcode_extended_rm3_tilde:
00151     case opcode_extended_cm3_tilde:
00152     case opcode_extended_off:
00153         goto yuck;
00154 
00155     case opcode_extended_display_print:
00156         {
00157             display value;
00158             unsigned addr = address;
00159             if (!addr)
00160                 addr = wrap_address(addr);
00161             assert(addr >= 1 && addr <= 240);
00162             calculate_display_lrn(value, addr, programme[addr]);
00163             derived_print(value);
00164         }
00165         return;
00166 
00167     case opcode_extended_paper_feed:
00168         derived_feed();
00169         return;
00170 
00171     case opcode_extended_program_print:
00172         program_print();
00173         return;
00174 
00175     default:
00176         if (op > 0 && op < 127)
00177             goto binary;
00178     case opcode_extended_rounding_switch_up:
00179     case opcode_extended_rounding_switch_off:
00180     case opcode_extended_rounding_switch_down:
00181     case opcode_extended_decimal_point_selector_0:
00182     case opcode_extended_decimal_point_selector_1:
00183     case opcode_extended_decimal_point_selector_2:
00184     case opcode_extended_decimal_point_selector_3:
00185     case opcode_extended_decimal_point_selector_4:
00186     case opcode_extended_decimal_point_selector_5:
00187     case opcode_extended_decimal_point_selector_6:
00188     case opcode_extended_decimal_point_selector_7:
00189     case opcode_extended_decimal_point_selector_8:
00190     case opcode_extended_decimal_point_selector_9:
00191     case opcode_extended_decimal_point_selector_10:
00192     case opcode_extended_decimal_point_selector_11:
00193     case opcode_extended_decimal_point_selector_12:
00194     case opcode_extended_decimal_point_selector_float:
00195     case opcode_extended_goto_000:
00196     case opcode_extended_goto_001:
00197     case opcode_extended_goto_002:
00198     case opcode_extended_goto_003:
00199     case opcode_extended_goto_004:
00200     case opcode_extended_goto_005:
00201     case opcode_extended_goto_006:
00202     case opcode_extended_goto_007:
00203     case opcode_extended_goto_008:
00204     case opcode_extended_goto_009:
00205     case opcode_extended_goto_010:
00206     case opcode_extended_goto_011:
00207     case opcode_extended_goto_012:
00208     case opcode_extended_goto_013:
00209     case opcode_extended_goto_014:
00210     case opcode_extended_goto_015:
00211     case opcode_extended_goto_100:
00212     case opcode_extended_goto_101:
00213     case opcode_extended_goto_102:
00214     case opcode_extended_goto_103:
00215     case opcode_extended_goto_104:
00216     case opcode_extended_goto_105:
00217     case opcode_extended_goto_106:
00218     case opcode_extended_goto_107:
00219     case opcode_extended_goto_108:
00220     case opcode_extended_goto_109:
00221     case opcode_extended_goto_110:
00222     case opcode_extended_goto_111:
00223     case opcode_extended_goto_112:
00224     case opcode_extended_goto_113:
00225     case opcode_extended_goto_114:
00226     case opcode_extended_goto_115:
00227     case opcode_extended_goto_200:
00228     case opcode_extended_goto_201:
00229     case opcode_extended_goto_202:
00230     case opcode_extended_goto_203:
00231     case opcode_extended_goto_204:
00232     case opcode_extended_goto_205:
00233     case opcode_extended_goto_206:
00234     case opcode_extended_goto_207:
00235     case opcode_extended_goto_208:
00236     case opcode_extended_goto_209:
00237     case opcode_extended_goto_210:
00238     case opcode_extended_goto_211:
00239     case opcode_extended_goto_212:
00240     case opcode_extended_goto_213:
00241     case opcode_extended_goto_214:
00242     case opcode_extended_goto_215:
00243     case opcode_extended_goto_300:
00244     case opcode_extended_goto_301:
00245     case opcode_extended_goto_302:
00246     case opcode_extended_goto_303:
00247     case opcode_extended_goto_304:
00248     case opcode_extended_goto_305:
00249     case opcode_extended_goto_306:
00250     case opcode_extended_goto_307:
00251     case opcode_extended_goto_308:
00252     case opcode_extended_goto_309:
00253     case opcode_extended_goto_310:
00254     case opcode_extended_goto_311:
00255     case opcode_extended_goto_312:
00256     case opcode_extended_goto_313:
00257     case opcode_extended_goto_314:
00258     case opcode_extended_goto_315:
00259     case opcode_extended_goto_400:
00260     case opcode_extended_goto_401:
00261     case opcode_extended_goto_402:
00262     case opcode_extended_goto_403:
00263     case opcode_extended_goto_404:
00264     case opcode_extended_goto_405:
00265     case opcode_extended_goto_406:
00266     case opcode_extended_goto_407:
00267     case opcode_extended_goto_408:
00268     case opcode_extended_goto_409:
00269     case opcode_extended_goto_410:
00270     case opcode_extended_goto_411:
00271     case opcode_extended_goto_412:
00272     case opcode_extended_goto_413:
00273     case opcode_extended_goto_414:
00274     case opcode_extended_goto_415:
00275     case opcode_extended_goto_500:
00276     case opcode_extended_goto_501:
00277     case opcode_extended_goto_502:
00278     case opcode_extended_goto_503:
00279     case opcode_extended_goto_504:
00280     case opcode_extended_goto_505:
00281     case opcode_extended_goto_506:
00282     case opcode_extended_goto_507:
00283     case opcode_extended_goto_508:
00284     case opcode_extended_goto_509:
00285     case opcode_extended_goto_510:
00286     case opcode_extended_goto_511:
00287     case opcode_extended_goto_512:
00288     case opcode_extended_goto_513:
00289     case opcode_extended_goto_514:
00290     case opcode_extended_goto_515:
00291     case opcode_extended_goto_600:
00292     case opcode_extended_goto_601:
00293     case opcode_extended_goto_602:
00294     case opcode_extended_goto_603:
00295     case opcode_extended_goto_604:
00296     case opcode_extended_goto_605:
00297     case opcode_extended_goto_606:
00298     case opcode_extended_goto_607:
00299     case opcode_extended_goto_608:
00300     case opcode_extended_goto_609:
00301     case opcode_extended_goto_610:
00302     case opcode_extended_goto_611:
00303     case opcode_extended_goto_612:
00304     case opcode_extended_goto_613:
00305     case opcode_extended_goto_614:
00306     case opcode_extended_goto_615:
00307     case opcode_extended_goto_700:
00308     case opcode_extended_goto_701:
00309     case opcode_extended_goto_702:
00310     case opcode_extended_goto_703:
00311     case opcode_extended_goto_704:
00312     case opcode_extended_goto_705:
00313     case opcode_extended_goto_706:
00314     case opcode_extended_goto_707:
00315     case opcode_extended_goto_708:
00316     case opcode_extended_goto_709:
00317     case opcode_extended_goto_710:
00318     case opcode_extended_goto_711:
00319     case opcode_extended_goto_712:
00320     case opcode_extended_goto_713:
00321     case opcode_extended_goto_714:
00322     case opcode_extended_goto_715:
00323         yuck:
00324         on_error
00325         (
00326             "'%s' is not valid in Program Mode %s",
00327             opcode_name(op).c_str(),
00328             program_mode_name(program_mode)
00329         );
00330         break;
00331     }
00332 }