home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BDSC / BDSC-1 / NOCLR.C < prev    next >
Text File  |  2000-06-30  |  2KB  |  74 lines

  1.  
  2. noclrex()
  3. /*
  4.  
  5.     NOCLREX - Do not clear externals.
  6.  
  7.     11/15/82 - David A. Gewirtz
  8.  
  9.     This function is used to hack up version 1.5 of Leor's    
  10.  
  11. BDS C compiler. The C.CCC runtime package automatically clears 
  12.  
  13. the external data area before executing the compiled program.  
  14.  
  15. For most programs, this is fine, but for a program like CHDIR, 
  16.  
  17. which writes itself back out and counts on preinitialized 
  18.  
  19. externals, it is no good at all. So the noclrex() hack is used to 
  20.  
  21. cause C.CCC to bypass the 'clear externals' phase of the run-time 
  22.  
  23. initialization.  As C.CCC may be different for each version this 
  24.  
  25. routine should be checked.  The following code is part of the 
  26.  
  27. 'init' subroutine of the C.CCC runtime package:
  28.  
  29.  0447 2A1B01        LHLD    FRERAM    ;CLEAR EXTERNALS
  30.  044A EB            XCHG
  31.  044B 2A1501        LHLD    EXTRNS
  32.  044E CDFA02        CALL     CMH
  33.  0451 19            DAD    D    ;HL NOW HOLDS SIZE OF EXTERNAL DATA AREA
  34.  0452 7C        CLREX:    MOV     A,H    ;CLEAR ENTIRE EXTERNAL AREA
  35.  0453 B5            ORA    L
  36.  0454 CA5E04        JZ    CLREX2
  37.  0457 1B            DCX    D
  38.  0458 2B            DCX    H
  39.  0459 AF            XRA    A
  40.  045A 12            STAX    D
  41.  045B C35204        JMP    CLREX
  42.                 
  43.  045E AF        CLREX2:    XRA    A
  44.  
  45.     This function puts a JMP CLREX2 at location 0x447,
  46.     thereby effectively bypassing the clearing mechanisms
  47.     for programs based on this image.
  48.  
  49.     For those who believe in the sanctity of the original 
  50. program, as well as thos who really don't wish to see awful
  51. and unglamorous hacks, I have not put this in the original programs.
  52.     
  53.     If you have a need for it, simply compile this function
  54. and make a call of the form:
  55.  
  56.     noclrex();
  57.  
  58. and all will be well.
  59.  
  60.     Finally, please realize this this in no way affects the
  61. currently running program, only the program created from the
  62. current image.  
  63.  
  64. */
  65. {
  66.     poke(0x447,0xc3);    /* The JMP instruction */
  67.     poke(0x448,0x5e);    /* low order address */
  68.     poke(0x449,0x04);    /* high order */
  69.  
  70.     /* That's it ... just remember to change this whenever
  71.        C.CCC is changed or a new version is used */
  72. }
  73.  
  74.