root/src/dps8/dps8.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 6965b612-f62e-11ec-a432-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2012-2016 Harry Reed
   9  * Copyright (c) 2012 Dave Jordan
  10  * Copyright (c) 2013-2018 Charles Anthony
  11  * Copyright (c) 2016 Jean-Michel Merliot
  12  * Copyright (c) 2021-2025 The DPS8M Development Team
  13  *
  14  * This software is made available under the terms of the ICU License.
  15  * See the LICENSE.md file at the top-level directory of this distribution.
  16  *
  17  * ---------------------------------------------------------------------------
  18  */
  19 
  20 #if !defined(DPS8_H)
  21 # define DPS8_H
  22 
  23 # if defined(__FAST_MATH__)
  24 #  error __FAST_MATH__ is unsupported
  25 # endif /* if defined(__FAST_MATH__) */
  26 
  27 # include <stdio.h>
  28 # include <stdbool.h>
  29 # if defined(THREADZ) || defined(LOCKLESS)
  30 #  include <stdatomic.h>
  31 # endif /* defined(THREADZ) || defined(LOCKLESS) */
  32 # include <errno.h>
  33 # include <inttypes.h>
  34 # include <sys/stat.h>
  35 # include <sys/time.h>
  36 # include <setjmp.h>  // for setjmp/longjmp used by interrupts & faults
  37 
  38 # if (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__)
  39 #  include <libgen.h>  // needed for macOS and Android
  40 # endif
  41 
  42 # include "dps8_sir.h"
  43 
  44 # if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__x86_64__) || defined(__AMD64) || \
  45      defined(_M_IX86) || defined(__i386) || defined(__i486) || defined(__i586) || defined(__i686) || defined(__ix86)
  46 #  if HAS_INCLUDE(<immintrin.h>)
  47 #   include <immintrin.h>
  48 #  endif
  49 # endif
  50 
  51 # undef HAS_ATTRIBUTE
  52 # if defined __has_attribute && (defined(__clang__) || defined(__GNUC__))
  53 #  define HAS_ATTRIBUTE(atr) __has_attribute(atr)
  54 # else
  55 #  define HAS_ATTRIBUTE(atr) 0
  56 # endif
  57 
  58 # undef HOT
  59 # if HAS_ATTRIBUTE(hot)
  60 #  define HOT __attribute__((hot))
  61 # endif
  62 # if !defined(HOT)
  63 #  define HOT
  64 # endif
  65 
  66 // Rarely used code called from hot paths (e.g. the T&D parts of the
  67 // memory routines): kept out of line, so that the callers stay small
  68 // enough to inline
  69 # undef COLD
  70 # if HAS_ATTRIBUTE(cold) && HAS_ATTRIBUTE(noinline)
  71 #  define COLD __attribute__((cold, noinline))
  72 # endif
  73 # if !defined(COLD)
  74 #  define COLD
  75 # endif
  76 
  77 // For code compiled twice from one source (see FULL_MODEL_ON in
  78 // dps8_cpu.h): the shared body is always inlined into its two copies
  79 # undef ALWAYS_INLINE
  80 # if HAS_ATTRIBUTE(always_inline)
  81 #  define ALWAYS_INLINE inline __attribute__((always_inline))
  82 # else
  83 #  define ALWAYS_INLINE inline
  84 # endif
  85 # undef NO_INLINE
  86 # if HAS_ATTRIBUTE(noinline)
  87 #  define NO_INLINE __attribute__((noinline))
  88 # else
  89 #  define NO_INLINE
  90 # endif
  91 
  92 # undef HAS_BUILTIN
  93 # if defined __has_builtin
  94 #  define HAS_BUILTIN(builtin) __has_builtin(builtin)
  95 # else
  96 #  define HAS_BUILTIN(builtin) 0
  97 # endif
  98 
  99 # if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) || defined(_AIX)
 100 #  undef setjmp
 101 #  define setjmp _setjmp
 102 #  undef longjmp
 103 #  define longjmp _longjmp
 104 # endif
 105 
 106 typedef int64_t __int64_t;
 107 
 108 # if defined(NEED_128)
 109 typedef struct { uint64_t h; uint64_t l; } x__uint128_t;
 110 typedef struct { int64_t h;  uint64_t l; } x__int128_t;
 111 #  define construct_128(h, l) ((uint128) { (h), (l) })
 112 #  define construct_s128(h, l) ((int128) { (h), (l) })
 113 # endif /* if defined(NEED_128) */
 114 
 115 // Quiet compiler unused warnings
 116 # define QUIET_UNUSED
 117 
 118 // Enable speed over debugging if not TESTING
 119 # if !defined(TESTING)
 120 #  define SPEED
 121 # endif /* if !defined(TESTING) */
 122 
 123 // Experimental dial_out line disconnect delay
 124 // FNP polled ~100Hz; 2 secs. is 200 polls
 125 # define DISC_DELAY 200
 126 
 127 // Micro-cache
 128 # undef OLDAPP
 129 # define UCACHE_STATS
 130 
 131 // Shift/rotate instruction barrel shifter
 132 # define BARREL_SHIFTER 1
 133 
 134 //
 135 // Dependencies
 136 //
 137 
 138 # if defined(PANEL68)
 139 #  define PNL(x) x
 140 # else
 141 #  define PNL(x)
 142 # endif /* if defined(PANEL68) */
 143 
 144 # define L68_(x) if (cpu.tweaks.l68_mode) { x }
 145 # define DPS8M_(x) if (! cpu.tweaks.l68_mode) { x }
 146 
 147 // Debugging tool
 148 # if defined(TESTING)
 149 #  define IF1 if (cpu.tweaks.isolts_mode)
 150 # else
 151 #  define IF1 if (0)
 152 # endif /* if defined(TESTING) */
 153 
 154 // DPS8-M supports Hex Mode Floating Point
 155 # define HEX_MODE
 156 
 157 // Instruction profiler
 158 // #define MATRIX
 159 
 160 // Run TR on work done, not wall clock.
 161 // Define one of these; tied to memory access (MEM)
 162 //  or to instruction execution (EXEC)
 163 //# define TR_WORK_MEM
 164 # define TR_WORK_EXEC
 165 
 166 // Storage for main thread id
 167 extern pthread_t main_thread_id;
 168 
 169 // Multi-threading may require 'volatile' in some places
 170 # if defined(THREADZ) || defined(LOCKLESS)
 171 #  define vol volatile
 172 #  define volAtomic volatile _Atomic
 173 # else
 174 #  define vol
 175 #  define volAtomic
 176 # endif /* if defined(THREADZ) || defined(LOCKLESS) */
 177 
 178 # if !defined(NEED_128)
 179 #  if defined(PRIu64)
 180 #   undef PRIu64
 181 #  endif /* if defined(PRIu64) */
 182 #  if !defined(PRIu64)
 183 #   define PRIu64 "llu"
 184 #  endif /* if !defined(PRIu64) */
 185 #  if defined(PRId64)
 186 #   undef PRId64
 187 #  endif /* if defined(PRId64) */
 188 #  if !defined(PRId64)
 189 #   define PRId64 "lld"
 190 #  endif /* if !defined(PRId64) */
 191 #  if defined(PRIo64)
 192 #   undef PRIo64
 193 #  endif /* if defined(PRIo64) */
 194 #  if !defined(PRIo64)
 195 #   if defined(__HAIKU__)
 196 #    define PRIo64 "lo"
 197 #    undef llo
 198 #    define llo "lo"
 199 #   else
 200 #    define PRIo64 "llo"
 201 #   endif /* if defined(__HAIKU__) */
 202 #  endif /* if !defined(PRIo64) */
 203 # endif /* if !defined(NEED_128) */
 204 
 205 # include "../simh/sim_defs.h"           /* simulator defns */
 206 # include "../simh/sim_tape.h"
 207 
 208 # if defined(__MINGW32__)
 209 #  include <stdint.h>
 210 typedef t_uint64    u_int64_t;
 211 # endif /* if defined(__MINGW32__) */
 212 # if defined(__HAIKU__)
 213 #  include <stdint.h>
 214 typedef long int64;
 215 typedef unsigned long uint64;
 216 # endif /* if defined(__HAIKU__) */
 217 # if !defined(__HAIKU__)
 218 typedef t_uint64    uint64;
 219 # endif /* if !defined(__HAIKU__) */
 220 # if !defined(_AIX)
 221 #  if !defined(__HAIKU__)
 222 typedef t_int64     int64;
 223 #  endif /* if !defined(__HAIKU__) */
 224 # else
 225 typedef long        int64;
 226 # endif /* if !defined(_AIX) */
 227 
 228 /* Data types */
 229 
 230 typedef uint8        word1;
 231 typedef uint8        word2;
 232 typedef uint8        word3;
 233 typedef uint8        word4;
 234 typedef uint8        word5;
 235 typedef uint8        word6;
 236 typedef uint8        word7;
 237 typedef uint8        word8;
 238 typedef int8         word8s; // signed 8-bit quantity
 239 typedef uint16       word9;
 240 typedef uint16       word10;
 241 typedef uint16       word11;
 242 typedef uint16       word12;
 243 typedef int16        word12s;
 244 typedef uint16       word13;
 245 typedef uint16       word14;
 246 typedef uint16       word15;
 247 typedef uint16       word16;
 248 typedef uint32       word17;
 249 typedef uint32       word18;
 250 typedef uint32       word19;
 251 typedef int32        word18s;
 252 typedef uint32       word20;
 253 typedef int32        word20s;
 254 typedef uint32       word21;
 255 typedef uint32       word22;
 256 typedef uint32       word23;
 257 typedef uint32       word24;
 258 typedef uint32       word27;
 259 typedef int32        word27s;
 260 typedef uint32       word28;
 261 typedef uint32       word32;
 262 typedef uint64       word34;
 263 typedef uint64       word36;
 264 typedef uint64       word37;
 265 typedef uint64       word38;
 266 typedef int64        word38s;
 267 typedef int64        word36s;
 268 # if !defined(NEED_128)
 269 typedef __uint128_t  word72;
 270 typedef __int128_t   word72s;
 271 typedef __uint128_t  word73;
 272 typedef __uint128_t  word74;
 273 typedef __uint128_t  uint128;
 274 typedef __int128_t   int128;
 275 # else
 276 typedef x__uint128_t word72;
 277 typedef x__int128_t  word72s;
 278 typedef x__uint128_t word73;
 279 typedef x__uint128_t word74;
 280 typedef x__uint128_t uint128;
 281 typedef x__int128_t  int128;
 282 # endif /* if !defined(NEED_128) */
 283 
 284 typedef word36       float36;   // single precision float
 285 typedef word72       float72;   // double precision float
 286 
 287 typedef unsigned int uint;   //-V677   // efficient unsigned int, at least 32 bits
 288 
 289 # include "dps8_simh.h"
 290 # include "dps8_sys.h"
 291 # include "dps8_math128.h"
 292 # include "dps8_hw_consts.h"
 293 # include "dps8_em_consts.h"
 294 
 295 # define SETF(flags, x)       flags = ((flags) |  (x))
 296 # define CLRF(flags, x)       flags = ((flags) & ~(x))
 297 # define TSTF(flags, x)       (((flags) & (x)) ? 1 : 0)
 298 # define SCF(cond, flags, x)  { if (cond) SETF((flags), x); else CLRF((flags), x); }
 299 
 300 # define SETBIT(dst, bitno)   ((dst)  |  (1LLU << (bitno)))
 301 # define CLRBIT(dst, bitno)   ((dst)  & ~(1LLU << (bitno)))
 302 # define TSTBIT(dst, bitno)   (((dst) &  (1LLU << (bitno))) ? 1: 0)
 303 
 304 typedef enum
 305   {
 306     UNKNOWN_CYCLE = 0,
 307     OPERAND_STORE,
 308     OPERAND_READ,
 309     INDIRECT_WORD_FETCH,
 310     RTCD_OPERAND_FETCH,
 311     INSTRUCTION_FETCH,
 312     APU_DATA_READ,
 313     APU_DATA_STORE,
 314     ABSA_CYCLE,
 315 # if defined(LOCKLESS)
 316     OPERAND_RMW,
 317     APU_DATA_RMW,
 318 # endif /* if defined(LOCKLESS) */
 319   } processor_cycle_type;
 320 
 321 # if !defined(LOCKLESS)
 322 #  define OPERAND_RMW   OPERAND_READ
 323 #  define APU_DATA_RMW  APU_DATA_READ
 324 # endif /* if !defined(LOCKLESS) */
 325 
 326 # if !defined(EIS_PTR4)
 327 // some breakpoint stuff ...
 328 typedef enum
 329   {
 330     UnknownMAT       = 0,
 331     OperandRead,
 332     OperandWrite,
 333     viaPR
 334   } MemoryAccessType;
 335 # endif
 336 
 337 // get 6-bit char @ pos
 338 # define GETCHAR(src, pos) (word6)(((word36)src >> (word36)((5 - pos) * 6)) & 077)
 339 // get 9-bit byte @ pos
 340 # define GETBYTE(src, pos) (word9)(((word36)src >> (word36)((3 - pos) * 9)) & 0777)
 341 
 342 # if defined(NEED_128)
 343 #  define YPAIRTO72(ypair) construct_128 ((ypair[0] >> 28) & MASK8,    \
 344                                          ((ypair[0] & MASK28) << 36) | \
 345                                           (ypair[1] & MASK36));
 346 # else
 347 #  define YPAIRTO72(ypair)    (((((word72)(ypair[0] & DMASK)) << 36) | \
 348                                           (ypair[1] & DMASK)) & MASK72)
 349 # endif /* if defined(NEED_128) */
 350 
 351 # define GET_TALLY(src) (((src) >> 6) & MASK12)   // 12-bits
 352 # define GET_DELTA(src)  ((src) & MASK6)          // 6-bits
 353 
 354 # if !defined(max)
 355 #  define max(a,b)   max2((a),(b))
 356 # endif /* if !defined(max) */
 357 # define max2(a,b)   ((a) > (b) ? (a) : (b))
 358 # define max3(a,b,c) max((a), max((b),(c)))
 359 
 360 # if !defined(min)
 361 #  define min(a,b)   min2((a),(b))
 362 # endif /* if !defined(min) */
 363 # define min2(a,b)   ((a) < (b) ? (a) : (b))
 364 # define min3(a,b,c) min((a), min((b),(c)))
 365 
 366 // opcode metadata (flag) ...
 367 typedef enum
 368   {
 369     READ_OPERAND    = (1U <<  0),  // fetches/reads operand (CA) from memory
 370     STORE_OPERAND   = (1U <<  1),  // stores/writes operand to memory (its a STR-OP)
 371 # define RMW             (READ_OPERAND | STORE_OPERAND) // a Read-Modify-Write instruction
 372     READ_YPAIR      = (1U <<  2),  // fetches/reads Y-pair operand (CA) from memory
 373     STORE_YPAIR     = (1U <<  3),  // stores/writes Y-pair operand to memory
 374     READ_YBLOCK8    = (1U <<  4),  // fetches/reads Y-block8 operand (CA) from memory
 375     NO_RPT          = (1U <<  5),  // Repeat instructions not allowed
 376 //#define NO_RPD          (1U << 6)
 377     NO_RPL          = (1U <<  7),
 378 //#define NO_RPX          (NO_RPT | NO_RPD | NO_RPL)
 379     READ_YBLOCK16   = (1U <<  8),  // fetches/reads Y-block16 operands from memory
 380     STORE_YBLOCK16  = (1U <<  9),  // fetches/reads Y-block16 operands from memory
 381     TRANSFER_INS    = (1U << 10),  // a transfer instruction
 382     TSPN_INS        = (1U << 11),  // a TSPn instruction
 383     CALL6_INS       = (1U << 12),  // a call6 instruction
 384     PREPARE_CA      = (1U << 13),  // prepare TPR.CA for instruction
 385     STORE_YBLOCK8   = (1U << 14),  // stores/writes Y-block8 operand to memory
 386     IGN_B29         = (1U << 15),  // Bit-29 has an instruction specific meaning. Ignore.
 387     NO_TAG          = (1U << 16),  // tag is interpreted differently and for addressing purposes is effectively 0
 388     PRIV_INS        = (1U << 17),  // privileged instruction
 389     NO_BAR          = (1U << 18),  // not allowed in BAR mode
 390 //  NO_XEC          = (1U << 19),  // can't be executed via xec/xed
 391     NO_XED          = (1U << 20),  // No execution via XEC/XED instruction
 392 
 393 // EIS operand types
 394 
 395 # define EOP_ALPHA 1U
 396 
 397 // bits 21, 22
 398     EOP1_ALPHA      = (EOP_ALPHA << 21),
 399     EOP1_MASK       = (3U << 21),
 400 # define EOP1_SHIFT 21
 401 
 402 // bits 23, 24
 403     EOP2_ALPHA      = (EOP_ALPHA << 23),
 404     EOP2_MASK       = (3U << 23),
 405 # define EOP2_SHIFT 23
 406 
 407 // bits 25, 26
 408     EOP3_ALPHA      = (EOP_ALPHA << 25),
 409     EOP3_MASK       = (3U << 25),
 410 # define EOP3_SHIFT 25
 411 
 412     READ_YBLOCK32   = (1U << 27),  // fetches/reads Y-block16 operands from memory
 413     STORE_YBLOCK32  = (1U << 28),  // fetches/reads Y-block16 operands from memory
 414   } opc_flag;
 415 
 416 // opcode metadata (disallowed) modifications
 417 enum opc_mod
 418   {
 419     NO_DU           = (1U << 0),   // No DU modification allowed (Can these 2 be combined into 1?)
 420     NO_DL           = (1U << 1),   // No DL modification allowed
 421 # define NO_DUDL    (NO_DU | NO_DL)
 422 
 423     NO_CI           = (1U << 2),   // No character indirect modification (can these next 3 be combined?
 424     NO_SC           = (1U << 3),   // No sequence character modification
 425     NO_SCR          = (1U << 4),   // No sequence character reverse modification
 426 # define NO_CSS     (NO_CI | NO_SC | NO_SCR)
 427 
 428 # define NO_DLCSS   (NO_DU   | NO_CSS)
 429 # define NO_DDCSS   (NO_DUDL | NO_CSS)
 430 
 431     ONLY_AU_QU_AL_QL_XN = (1U << 5)    // None except au, qu, al, ql, xn
 432   };
 433 
 434 // None except au, qu, al, ql, xn for MF1 and REG
 435 // None except du, au, qu, al, ql, xn for MF2
 436 // None except au, qu, al, ql, xn for MF1, MF2, and MF3
 437 
 438 # define IS_NONE(tag) (!(tag))
 439 /*! non-tally: du or dl */
 440 # define IS_DD(tag) ((_TM(tag) != 040U) && \
 441     ((_TD(tag) == 003U) || (_TD(tag) == 007U)))
 442 /*! tally: ci, sc, or scr */
 443 # define IS_CSS(tag) ((_TM(tag) == 040U) && \
 444     ((_TD(tag) == 050U) || (_TD(tag) == 052U) || \
 445     (_TD(tag) == 045U)))
 446 # define IS_DDCSS(tag) (IS_DD(tag) || IS_CSS(tag))
 447 /*! just dl or css */
 448 # define IS_DCSS(tag) (((_TM(tag) != 040U) && (_TD(tag) == 007U)) || IS_CSS(tag))
 449 
 450 // !%WRD  ~0200000  017
 451 // !%9    ~0100000  027
 452 // !%6    ~0040000  033
 453 // !%4    ~0020000  035
 454 // !%1    ~0010000  036
 455 enum reg_use { is_WRD =  0174000,
 456                is_9  =   0274000,
 457                is_6  =   0334000,
 458                is_4  =   0354000,
 459                is_1  =   0364000,
 460                is_DU =   04000,
 461                is_OU =   02000,
 462                ru_A  =   02000 | 01000,
 463                ru_Q  =   02000 |  0400,
 464                ru_X0 =   02000 |  0200,
 465                ru_X1 =   02000 |  0100,
 466                ru_X2 =   02000 |   040,
 467                ru_X3 =   02000 |   020,
 468                ru_X4 =   02000 |   010,
 469                ru_X5 =   02000 |    04,
 470                ru_X6 =   02000 |    02,
 471                ru_X7 =   02000 |    01,
 472                ru_none = 02000 |     0 };
 473 //, ru_notou = 1024 };
 474 
 475 # define ru_AQ (ru_A | ru_Q)
 476 # define ru_Xn(n) (1 << (7 - (n)))
 477 
 478 // Basic + EIS opcodes .....
 479 struct opcode_s {
 480     const char *mne;       // mnemonic
 481     opc_flag flags;        // various and sundry flags
 482     enum opc_mod mods;          // disallowed addr mods
 483     uint ndes;             // number of operand descriptor words for instruction (mw EIS)
 484     enum reg_use reg_use;  // register usage
 485 };
 486 
 487 // operations stuff
 488 
 489 /*! Y of instruc word */
 490 # define Y(i) (i & MASKHI18)
 491 /*! X from opcodes in instruc word */
 492 # define OPSX(i) ((i & 0007000LLU) >> 9)
 493 /*! X from OP_* enum, and X from  */
 494 # define X(i) (i & 07U)
 495 
 496 enum { OP_1     = 00001U,
 497     OP_E        = 00002U,
 498     OP_BAR      = 00003U,
 499     OP_IC       = 00004U,
 500     OP_A        = 00005U,
 501     OP_Q        = 00006U,
 502     OP_AQ       = 00007U,
 503     OP_IR       = 00010U,
 504     OP_TR       = 00011U,
 505     OP_REGS     = 00012U,
 506 
 507     /* 645/6180 */
 508     OP_CPR      = 00021U,
 509     OP_DBR      = 00022U,
 510     OP_PTP      = 00023U,
 511     OP_PTR      = 00024U,
 512     OP_RA       = 00025U,
 513     OP_SDP      = 00026U,
 514     OP_SDR      = 00027U,
 515 
 516     OP_X        = 01000U
 517 };
 518 
 519 enum eCAFoper {
 520     unknown = 0,
 521     readCY,
 522     writeCY,
 523     rmwCY,      // Read-Modify-Write
 524 //    readCYpair,
 525 //    writeCYpair,
 526 //    readCYblock8,
 527 //    writeCYblock8,
 528 //    readCYblock16,
 529 //    writeCYblock16,
 530 
 531     prepareCA,
 532 };
 533 typedef enum eCAFoper eCAFoper;
 534 
 535 # define READOP(i) ((bool) (i->info->flags    &  \
 536                            (READ_OPERAND      |  \
 537                             READ_YPAIR        |  \
 538                             READ_YBLOCK8      |  \
 539                             READ_YBLOCK16     |  \
 540                             READ_YBLOCK32)))
 541 
 542 # define WRITEOP(i) ((bool) (i->info->flags   &  \
 543                             (STORE_OPERAND    |  \
 544                              STORE_YPAIR      |  \
 545                              STORE_YBLOCK8    |  \
 546                              STORE_YBLOCK16   |  \
 547                              STORE_YBLOCK32)))
 548 
 549 // if it's both read and write it's a RMW
 550 # define RMWOP(i) ((bool) READOP(i) && WRITEOP(i))
 551 
 552 # define TRANSOP(i) ((bool) (i->info->flags & (TRANSFER_INS) ))
 553 
 554 //
 555 // EIS stuff ...
 556 //
 557 
 558 // Numeric operand descriptors
 559 
 560 // AL39 Table 4-3. Alphanumeric Data Type (TA) Codes
 561 enum
 562   {
 563     CTA9   = 0U, // 9-bit bytes
 564     CTA6   = 1U, // 6-bit characters
 565     CTA4   = 2U, // 4-bit decimal
 566     CTAILL = 3U  // Illegal
 567   };
 568 
 569 // TN - Type Numeric AL39 Table 4-3. Alphanumeric Data Type (TN) Codes
 570 enum
 571   {
 572     CTN9 = 0U,   // 9-bit
 573     CTN4 = 1U    // 4-bit
 574   };
 575 
 576 // S - Sign and Decimal Type (AL39 Table 4-4. Sign and Decimal Type (S) Codes)
 577 
 578 enum
 579   {
 580     CSFL = 0U,   // Floating-point, leading sign
 581     CSLS = 1U,   // Scaled fixed-point, leading sign
 582     CSTS = 2U,   // Scaled fixed-point, trailing sign
 583     CSNS = 3U    // Scaled fixed-point, unsigned
 584   };
 585 
 586 enum
 587   {
 588     // Address register flag. This flag controls interpretation of the ADDRESS
 589     // field of the operand descriptor just as the "A" flag controls
 590     // interpretation of the ADDRESS field of the basic and EIS single-word
 591     // instructions.
 592     MFkAR = 0x40U,
 593     // Register length control. If RL = 0, then the length (N) field of the
 594     // operand descriptor contains the length of the operand. If RL = 1, then
 595     // the length (N) field of the operand descriptor contains a selector value
 596     // specifying a register holding the operand length. Operand length is
 597     // interpreted as units of the data size (1-, 4-, 6-, or 9-bit) given in
 598     // the associated operand descriptor.
 599     MFkRL = 0x20U,
 600     // Indirect descriptor control. If ID = 1 for Mfk, then the kth word
 601     // following the instruction word is an indirect pointer to the operand
 602     // descriptor for the kth operand; otherwise, that word is the operand
 603     // descriptor.
 604     MFkID = 0x10U,
 605 
 606     MFkREGMASK = 0xfU
 607   };
 608 
 609 // EIS instruction take on a life of their own. Need to take into account
 610 // RNR/SNR/BAR etc.
 611 typedef enum
 612   {
 613     eisUnknown = 0,  // uninitialized
 614     eisTA      = 1,  // type alphanumeric
 615     eisTN      = 2,  // type numeric
 616     eisBIT     = 3   // bit string
 617   } eisDataType;
 618 
 619 typedef enum
 620   {
 621     eRWreadBit = 0,
 622     eRWwriteBit
 623   } eRW;
 624 
 625 // Misc constants and macros
 626 
 627 # define ARRAY_SIZE(a) ( sizeof(a) / sizeof((a)[0]) )
 628 
 629 # if defined(FREE)
 630 #  undef FREE
 631 # endif /* if defined(FREE) */
 632 # define FREE(p) do  \
 633   {                  \
 634     free((p));       \
 635     (p) = NULL;      \
 636   } while(0)
 637 
 638 # if defined(__GNUC__) || defined(__clang_version__)
 639 #  if !defined(LIKELY)
 640 #   define LIKELY(x) __builtin_expect(!!(x), 1)
 641 #  endif
 642 #  if !defined(UNLIKELY)
 643 #   define UNLIKELY(x) __builtin_expect(!!(x), 0)
 644 #  endif
 645 # else
 646 #  if !defined(LIKELY)
 647 #   define LIKELY(x) (x)
 648 #  endif
 649 #  if !defined(UNLIKELY)
 650 #   define UNLIKELY(x) (x)
 651 #  endif
 652 # endif
 653 
 654 # if defined (__MINGW64__) || \
 655     defined (__MINGW32__)  || \
 656     defined (__GNUC__)     || \
 657     defined (__clang_version__)
 658 #  define UNUSED    __attribute__ ((unused))
 659 # else
 660 #  define UNUSED
 661 # endif
 662 
 663 /* Detect proper "does not return" annotation */
 664 # if !defined(NO_RETURN)
 665 #  if defined(__STDC_VERSION__)
 666 #   if __STDC_VERSION__ >= 202311L
 667 #    define NO_RETURN [[noreturn]] /* C23-style */
 668 #   elif __STDC_VERSION__ >= 201112L
 669 #    define NO_RETURN _Noreturn /* C11-style */
 670 #   endif
 671 #  endif
 672 # endif
 673 # if !defined(NO_RETURN)
 674 #  if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || \
 675       defined(__xlc__) || defined(__ibmxl__)
 676 #   define NO_RETURN __attribute__((noreturn)) /* IBM/Sun/GNU-style */
 677 #  endif
 678 # endif
 679 # if !defined(NO_RETURN)
 680 #  define NO_RETURN /* Fallback */
 681 # endif
 682 
 683 # define MAX_DEV_NAME_LEN 64
 684 
 685 // Basic STDIO for MinGW
 686 # if !defined(__CYGWIN__)
 687 #  if defined(__MINGW32__) || defined(__MINGW64__) || defined(CROSS_MINGW32) || defined(CROSS_MINGW64) || defined(__QNX__)
 688 #   define WIN_STDIO    1
 689 #  endif
 690 # endif /* if !defined(__CYGWIN__) */
 691 
 692 //#define SYNCTEST
 693 
 694 #endif // if defined(DPS8_H)

/* [previous][next][first][last][top][bottom][index][help] */