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