home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / apple / aphimem.aqm / APHIMEM.ASM
Encoding:
Assembly Source File  |  1985-02-10  |  1.6 KB  |  42 lines

  1. ;                HIMEM.ASM Version 1.0
  2. ;            by Gordon Banks
  3. ;            2/28/81
  4. ;
  5. ;This program sets a "HIMEM" (to borrow a term from Apple BASIC)
  6. ;which serves to protect a region of memory from being overwritten
  7. ;by other programs (such as BASIC programs compiled by BASCOM).
  8. ;This is needed by Apple users since the usual method of protection
  9. ;is to use MOVCPM to lower the system in memory, but this is not
  10. ;currently being made available by Microsoft.  
  11. ;
  12. ;The system knows how much memory is available for transient programs
  13. ;by the jump vector in locations 6 and 7.  This vector is reset (to
  14. ;CC06 hex for 56k CP/M) every time a warm boot is done.  This program
  15. ;changes the reset routine to put a new vector into locations 6 and 7.
  16. ;This causes a jump to 3 locations before HIMEM.  This program then
  17. ;writes a jump to the old BDOS vector from HIMEM (around your program).
  18. ;
  19. BOOT    EQU    0    ;BOOT ADDRESS
  20. BDOS    EQU    5    ;BDOS ADDRESS JMP
  21. HIMEM    EQU    0BF00H    ;STARTING ADDRESS FOR PROTECTED ROUTINE
  22. RESET    EQU    0DAF0H    ;WHERE CP/M LOADS THE BDOS ADDRESS
  23. JUMP    EQU    0C3H    ;JMP OP-CODE
  24. ;
  25.     ORG    0100H
  26. ;
  27.     LDA    BDOS+2    ;WHAT VALUE IS ALREADY THERE
  28.     CPI    0CCH    ;THIS IS WHAT IS NORMALLY THERE
  29.     JZ     CONT    ;IT IS, SO CONTINUE
  30.     JMP    BOOT    ;IT IS NOT, SO ALREADY HAVE RUN HIMEM, EXIT
  31. ;
  32. CONT    LHLD     BDOS+1 ;LOAD CURRENT BDOS JMP 
  33.     SHLD    HIMEM-2    ;PUT IN FRONT OF HIMEM
  34.     MVI    A,JUMP    ;LOAD A JMP OP-CODE
  35.     STA    HIMEM-3    ;PUT IN FRONT OF BDOS ADDRESS
  36.     LXI    H,HIMEM-3 ;LOAD THE NEW JUMP-TO ADDRESS
  37.     SHLD    RESET+1    ;STORE IN RESET VECTOR
  38.     JMP     BOOT
  39. ;
  40.     END
  41.