types.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /****************************************************************************
  2. * dcc project general header
  3. * (C) Cristina Cifuentes, Mike van Emmerik
  4. ****************************************************************************/
  5. #pragma once
  6. #include <stdint.h>
  7. /**** Common definitions and macros ****/
  8. #ifdef __MSDOS__ /* Intel: 16 bit integer */
  9. typedef long Int; /* Int: 0x80000000..0x7FFFFFFF */
  10. typedef unsigned long flags32; /* 32 bits */
  11. typedef unsigned long dword; /* 32 bits */
  12. #define MAX 0x7FFFFFFF
  13. #else /* Unix: 32 bit integer */
  14. typedef int Int; /* Int: 0x80000000..0x7FFFFFFF */
  15. typedef unsigned int flags32; /* 32 bits */
  16. typedef unsigned int dword; /* 32 bits */
  17. #define MAX 0x7FFFFFFF
  18. #endif
  19. /* Type definitions used in the program */
  20. typedef unsigned char byte; /* 8 bits */
  21. typedef unsigned short word;/* 16 bits */
  22. typedef short int16; /* 16 bits */
  23. typedef unsigned char boolT; /* 8 bits */
  24. #if defined(__MSDOS__) | defined(WIN32)
  25. #define unlink _unlink // Compiler is picky about non Ansi names
  26. #endif
  27. #define TRUE 1
  28. #define FALSE 0
  29. #define SYNTHESIZED_MIN 0x100000 /* Synthesized labs use bits 21..32 */
  30. /* These are for C library signature detection */
  31. #define SYMLEN 16 /* Length of proc symbols, incl null */
  32. #define PATLEN 23 /* Length of proc patterns */
  33. #define WILD 0xF4 /* The wild byte */
  34. /****** MACROS *******/
  35. /* Macro reads a LH word from the image regardless of host convention */
  36. /* Returns a 16 bit quantity, e.g. C000 is read into an Int as C000 */
  37. //#define LH(p) ((int16)((byte *)(p))[0] + ((int16)((byte *)(p))[1] << 8))
  38. #define LH(p) ((word)((byte *)(p))[0] + ((word)((byte *)(p))[1] << 8))
  39. /* Macro reads a LH word from the image regardless of host convention */
  40. /* Returns a signed quantity, e.g. C000 is read into an Int as FFFFC000 */
  41. #define LH_SIGNED(p) (((byte *)(p))[0] + (((char *)(p))[1] << 8))
  42. /* Macro tests bit b for type t in prog.map */
  43. #define BITMAP(b, t) (prog.map[(b) >> 2] & ((t) << (((b) & 3) << 1)))
  44. /* Macro to convert a segment, offset definition into a 20 bit address */
  45. #define opAdr(seg,off) ((seg << 4) + off)
  46. /* duVal FLAGS */
  47. struct eDuVal
  48. {
  49. eDuVal()
  50. {
  51. def=use=val=0;
  52. }
  53. enum flgs
  54. {
  55. DEF=1,
  56. USE=2,
  57. VAL=4
  58. };
  59. int def :1; /* Variable was first defined than used */
  60. int use :1; /* Variable was first used than defined */
  61. int val :1; /* Variable has an initial value. 2 cases:
  62. * 1. When variable is used first (ie. global)
  63. * 2. When a value is moved into the variable
  64. * for the first time. */
  65. void setFlags(uint16_t x)
  66. {
  67. def = x&DEF;
  68. use = x&USE;
  69. val = x&VAL;
  70. }
  71. bool isUSE_VAL() {return use&&val;} /* Use and Val */
  72. };