types.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. enum flgs
  50. {
  51. DEF=1,
  52. USE=2,
  53. VAL=4
  54. };
  55. int def :1; /* Variable was first defined than used */
  56. int use :1; /* Variable was first used than defined */
  57. int val :1; /* Variable has an initial value. 2 cases:
  58. * 1. When variable is used first (ie. global)
  59. * 2. When a value is moved into the variable
  60. * for the first time. */
  61. void setFlags(uint16_t x)
  62. {
  63. def = x&DEF;
  64. use = x&USE;
  65. val = x&VAL;
  66. }
  67. bool isUSE_VAL() {return use&&val;} /* Use and Val */
  68. };