types.h 2.6 KB

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