home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 163_01 / cc4.c < prev    next >
Text File  |  1991-01-06  |  3KB  |  96 lines

  1. /*
  2. ** Small-C Compiler Version 2.0
  3. **
  4. ** Portions Copyright 1982 J. E. Hendrix
  5. **
  6. ** Modified for 8088/PCDOS by D. R. Hicks
  7. **
  8. ** Part 4
  9. **
  10. ** Most modifications that were necessary for the 8088 processor occurred
  11. ** in this Part.  The only other significant modification necessary was in
  12. ** Part 1 to accommodate the generation of code and data in separate segments.
  13. ** and to allow the generation of a function prologue so that BP could be
  14. ** used to address the current stack frame.  Most modifications necessary for
  15. ** the PCDOS environment occurred in the I/O and library routines.
  16. */
  17.  
  18. /*
  19. ** General scheme:
  20. **
  21. ** Primary register:  AX
  22. ** Secondary register:  BX
  23. ** Argument count register:  DX
  24. **
  25. ** Code and data are generated in separate segments (the stack is contained
  26. ** in the data segment).  CS points at the code segment.  DS, ES, and SS all
  27. ** point at the data segment.  Thus, a data address can be relative to any one
  28. ** of the three data segment pointers interchangeably.
  29. **
  30. ** The current stack frame is addressed by register BP, and addressing of
  31. ** arguments and local variables is done relative to BP (rather than relative
  32. ** to SP as was done in the 8080 version).  Thus, all local variables are
  33. ** addressed with negative offsets from PB, while arguments are addressed
  34. ** with positive offsets from BP.
  35. **
  36. ** A stack frame looks as follows (stack grows down -- highest addresses first)
  37. **
  38. **   Parameter 1
  39. **   Parameter 2
  40. **   ...
  41. **   Parameter N
  42. **   Instruction pointer (return address)
  43. **   Caller's BP                           <-- BP points here
  44. **   Local variables
  45. **   ...
  46. **   Local variables
  47. **   Evaluation stack entries
  48. **   ...
  49. **   Evaluation stack entries              <-- SP points here
  50. **
  51. ** Note that the saved BP values create a chain of stack frames.
  52. ** This feature can be used to generate a trace-back on errors.
  53. */
  54. #define NOCCARGC /* (be sure to remove if [f]printf is used anywhere) */
  55. #include "errno.h"
  56. #include "stdio.h"
  57. #include "cc.def"
  58.  
  59. /*
  60. ** external references in part 1
  61. */
  62. extern char
  63. #ifdef HASH
  64.   *mach,
  65. #endif
  66. #ifdef DYNAMIC
  67.   *macq,
  68. #else
  69.   macq[MACQSIZE],
  70. #endif
  71.   *stagenext, ssname[NAMESIZE];
  72. extern int
  73.   csp, dmode, output;
  74.  
  75. /*
  76. ** external references in part 2
  77. */
  78. extern int
  79. #ifdef HASH
  80.   search(),
  81. #else
  82.   findmac(),
  83. #endif
  84.   clearstage(), col(), cout(), getint(), getlabel(),
  85.   nl(), numeric(),  ol(), ot(), outbyte(), printlabel(),
  86.   lout(),  outdec(),  outstr(),  streq();
  87.  
  88. /*
  89. ** external references in part 3
  90. */
  91. extern int const();
  92.  
  93. #include "cc41.c"
  94. #include "cc42.c"
  95.  
  96.