1 /* lgp_defs.h: LGP simulator definitions 2 3 Copyright (c) 2004-2010, Robert M. Supnik 4 5 Permission is hereby granted, free of charge, to any person obtaining a 6 copy of this software and associated documentation files (the "Software"), 7 to deal in the Software without restriction, including without limitation 8 the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 and/or sell copies of the Software, and to permit persons to whom the 10 Software is furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22 Except as contained in this notice, the name of Robert M Supnik shall not be 23 be used in advertising or otherwise to promote the sale, use or other dealings 24 in this Software without prior written authorization from Robert M Supnik. 25 26 22-May-10 RMS Added check for 64b definitions 27 */ 28 29 #ifndef _LGP_DEFS_H_ 30 #define _LGP_DEFS_H_ 0 31 32 #include "sim_defs.h" /* simulator defns */ 33 34 #if defined(USE_INT64) || defined(USE_ADDR64) 35 #error "LGP-30 does not support 64b values!" 36 #endif 37 38 /* Simulator stop codes */ 39 40 #define STOP_STOP 1 /* STOP */ 41 #define STOP_IBKPT 2 /* breakpoint */ 42 #define STOP_OVF 3 /* overflow */ 43 #define STOP_NXDEV 4 /* non-existent device */ 44 #define STOP_STALL 5 /* IO stall */ 45 46 /* Memory */ 47 48 #define MEMSIZE 4096 /* memory size */ 49 #define AMASK 0xFFF /* addr mask */ 50 #define NTK_30 64 51 #define NSC_30 64 52 #define SCMASK_30 0x03F /* sector mask */ 53 #define NTK_21 32 54 #define NSC_21 128 55 #define SCMASK_21 0x07F 56 #define RPM 4000 /* rev/minutes */ 57 #define WPS ((NSC_30 * RPM) / 60) /* words/second */ 58 59 /* Architectural constants */ 60 61 #define SIGN 0x80000000 /* sign */ 62 #define DMASK 0xFFFFFFFF /* data mask */ 63 #define MMASK 0xFFFFFFFE /* memory mask */ 64 65 /* Instruction format */ 66 67 #define I_M_OP 0xF /* opcode */ 68 #define I_V_OP 16 69 #define I_OP (I_M_OP << I_V_OP) 70 #define I_GETOP(x) (((x) >> I_V_OP) & I_M_OP) 71 #define I_M_EA AMASK /* address */ 72 #define I_V_EA 2 73 #define I_EA (I_M_EA << I_V_EA) 74 #define I_GETEA(x) (((x) >> I_V_EA) & I_M_EA) 75 #define I_M_TK 0x3F /* LGP-30 char */ 76 #define I_V_TK 8 /* LGP-21 device */ 77 #define I_GETTK(x) (((x) >> I_V_TK) & I_M_TK) 78 79 /* Unit flags */ 80 81 #define UNIT_V_LGP21 (UNIT_V_UF + 0) 82 #define UNIT_V_MANI (UNIT_V_UF + 1) 83 #define UNIT_V_INPT (UNIT_V_UF + 2) 84 #define UNIT_V_OUTPT (UNIT_V_UF + 3) 85 #define UNIT_V_IN4B (UNIT_V_UF + 4) 86 #define UNIT_V_TTSS_D (UNIT_V_UF + 5) 87 #define UNIT_V_LGPH_D (UNIT_V_UF + 6) 88 #define UNIT_V_FLEX_D (UNIT_V_UF + 7) /* Flex default */ 89 #define UNIT_V_FLEX (UNIT_V_UF + 8) /* Flex format */ 90 #define UNIT_V_NOCS (UNIT_V_UF + 9) /* ignore cond stop */ 91 #define UNIT_LGP21 (1u << UNIT_V_LGP21) 92 #define UNIT_MANI (1u << UNIT_V_MANI) 93 #define UNIT_INPT (1u << UNIT_V_INPT) 94 #define UNIT_OUTPT (1u << UNIT_V_OUTPT) 95 #define UNIT_IN4B (1u << UNIT_V_IN4B) 96 #define UNIT_TTSS_D (1u << UNIT_V_TTSS_D) 97 #define UNIT_LGPH_D (1u << UNIT_V_LGPH_D) 98 #define UNIT_FLEX_D (1u << UNIT_V_FLEX_D) 99 #define UNIT_FLEX (1u << UNIT_V_FLEX) 100 #define UNIT_NOCS (1u << UNIT_V_NOCS) 101 #define Q_LGP21 (cpu_unit.flags & UNIT_LGP21) 102 #define Q_MANI (cpu_unit.flags & UNIT_MANI) 103 #define Q_INPT (cpu_unit.flags & UNIT_INPT) 104 #define Q_OUTPT (cpu_unit.flags & UNIT_OUTPT) 105 #define Q_IN4B (cpu_unit.flags & UNIT_IN4B) 106 107 /* IO return */ 108 109 #define IORETURN(f,v) ((f)? (v): SCPE_OK) /* stop on error */ 110 111 /* Significant characters */ 112 113 #define FLEX_LC 0x04 114 #define FLEX_UC 0x08 115 #define FLEX_CR 0x10 116 #define FLEX_BS 0x14 117 #define FLEX_CSTOP 0x20 118 #define FLEX_DEL 0x3F 119 120 /* LGP-21 device assignments */ 121 122 #define DEV_PT 0 123 #define DEV_TT 2 124 #define DEV_MASK 0x1F 125 #define DEV_SHIFT 62 126 127 /* Instructions */ 128 129 enum opcodes { 130 OP_Z, OP_B, OP_Y, OP_R, 131 OP_I, OP_D, OP_N, OP_M, 132 OP_P, OP_E, OP_U, OP_T, 133 OP_H, OP_C, OP_A, OP_S 134 }; 135 136 /* Prototypes */ 137 138 uint32 Read (uint32 ea); 139 void Write (uint32 ea, uint32 dat); 140 141 #endif 142