home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / AS02.ZIP / SYSPARM.ASM < prev    next >
Assembly Source File  |  1985-01-29  |  5KB  |  153 lines

  1. ;  SYSPARM.ASM - DKeels                             07/09/84
  2. ;----------------------------------------------------------------------------
  3. ;  This is a resident system process (RSP) which is to be loaded into memory 
  4. ;  at boot time.  
  5. ;  The program consists of two parts:  
  6. ;  1) An initialization routine sets up the interrupt mechanism and 
  7. ;  sets aside an area of memory which can be used for parameter passing 
  8. ;  between programs.  This memory is preserved upon exit (it becomes 
  9. ;  resident).
  10. ;  2) The interrupt mechanism, which remains resident, simply returns the
  11. ;  segment address of the parameter table in AX.
  12. ;----------------------------------------------------------------------------
  13. PAGE 66,132
  14.  
  15. ;NOTE:  The following equate is used to determine the size of the memory
  16. ;    block (in paragraphs) to leave resident.  It has been padded somewhat 
  17. ;    to absorb minor changes in the length of this program, and to 
  18. ;    compensate for some appearant bugs in DOS.  If the length
  19. ;    should change substantially, (eg, expanding PARM_AREA by 16 bytes), 
  20. ;    then add enough paragraphs to SYSPARM_LENGTH to compensate.
  21.  
  22. SYSPARM_LENGTH    EQU    0110H
  23.  
  24.  
  25. ABSOLUTE_0    SEGMENT    AT 0
  26.         ORG    4*77H
  27. INTERRUPT_77H    DD                ;interrupt 77H vector
  28. ABSOLUTE_0    ENDS
  29.  
  30.  
  31. STACK_SEG    SEGMENT STACK 'STACK'
  32.         DB    2 DUP('dkstack ')    ;stack space
  33. STACK_SEG    ENDS
  34.  
  35.  
  36. CODE        SEGMENT
  37.         ASSUME CS:CODE,DS:CODE,ES:CODE
  38. ENTRY_POINT:    JMP    INITIALIZE        ;jump to initialization routine
  39.  
  40. ORIGINAL_VECTOR    DD    ?            ;save original int 77h vector
  41. SYSPARM_ID_TAG    DB    'PMS/dlk'        ;used to prevent reloading
  42.         DB    2 DUP(0)        ;put load_table on para boundry
  43.  
  44. LOAD_TABLE    EQU    $            ;LOADer parameter area
  45. FILE_SPEC_1    DB    80 DUP(' ')        ;+0
  46.         DB    0            ;+80
  47. PARAMETER_1_LEN DB    0            ;+81
  48. PARAMETER_1    DB    80 DUP(' ')        ;+82
  49.         DB    13            ;+162
  50. FILE_SPEC_2    DB    80 DUP(' ')        ;+163
  51.         DB    0            ;+243
  52. PARAMETER_2_LEN DB    0            ;+244
  53. PARAMETER_2    DB    80 DUP(' ')        ;+245
  54.         DB    13            ;+325
  55.  
  56. COLOR_TABLE    EQU    $
  57. FOREGROUND    DW    07            ;+326
  58. BACKGROUND    DW    00            ;+328
  59. BORDER        DW    00            ;+330
  60. EMPHASIZED_FGD    DW    15            ;+332
  61. WINDOW_FGD    DW    00            ;+334
  62. WINDOW_BGD    DW    07            ;+336
  63.  
  64. TABLE_SIZE    DW    3600            ;(+338) current max. table size
  65. MAX_ENTRIES    DW    3600/18            ;(+340) current table entries
  66.  
  67. TABLE        DB    3600 DUP(' ')        ;cross-reference table
  68. PARM_AREA    DB    10 DUP(' ')        ;unused parameter area
  69.  
  70. ;CAUTION: Changing data configurations before this point could be dangerous!
  71. ;The size of the PARM_AREA can be expanded to 64K, but the SYSPARM_LENGTH
  72. ;(above) must be changed accordingly.
  73.  
  74. ;----------------------------------------------------------------------------
  75. ; This is the code to process the interrupts, once resident.  The 
  76. ; initialization routine points the interrupt vector to this routine.
  77. ;----------------------------------------------------------------------------
  78. INTERRUPT_CODE    PROC    FAR
  79.         ASSUME CS:CODE,DS:NOTHING,ES:NOTHING
  80.  
  81.         CMP    DX,'dk'            ;verify interrupt
  82.         JE    CONTINUE        ;if DX='dk', then do sysparm
  83.         JMP    ORIGINAL_VECTOR        ;else not a call to sysparm
  84.  
  85. CONTINUE:    MOV    AX,CS            ;segment address
  86.         INC    AX            ;plus offset (1 paragraph)
  87.         IRET
  88.  
  89. INTERRUPT_CODE    ENDP
  90.  
  91. ;INTERRUPT_END    DB    ?            ;mark end of resident code
  92.  
  93. ;************************* END OF RESIDENT CODE *****************************
  94.  
  95.  
  96. ;----------------------------------------------------------------------------
  97. ; Initialization routine saves original value of int 77h vector, then
  98. ; replaces vector with address of SYSPARM interrupt handler code.  This
  99. ; routine terminates and leaves the interrupt code and parm table resident.
  100. ;----------------------------------------------------------------------------
  101.  
  102. SYSPARM_LOAD    PROC    FAR
  103. INITIALIZE:
  104.         CLI                ;no interruptions, please
  105.         PUSH    DS            ;establish far return to DOS
  106.         SUB    AX,AX
  107.         PUSH    AX
  108.         MOV    ES,AX            ;ES -> 0000:xxxx
  109.         ASSUME    ES:ABSOLUTE_0
  110.         MOV    AX,WORD PTR ES:INTERRUPT_77H    ;get original vector
  111.         MOV    BX,WORD PTR ES:INTERRUPT_77H+2
  112.         MOV    WORD PTR DS:ORIGINAL_VECTOR,AX    ;save in code segment
  113.         MOV    WORD PTR DS:ORIGINAL_VECTOR+2,BX
  114.  
  115.     ;prevent reloading sysparm
  116.         MOV    ES,BX            ;ES -> seg of current int vect
  117.         LEA    DI,DS:SYSPARM_ID_TAG    ;DI -> offset to tag
  118.         PUSH    CS
  119.         POP    DS            ;DS -> code segment
  120.         MOV    SI,DI            ;SI -> offset to tag
  121.         MOV    CX,7            ;length of tag
  122.         CLD
  123.         REPE    CMPSB            ;DS:BYTE PTR [SI],ES:[DI]
  124.                         ;if sysparm tag is present
  125.         JZ    EARLY_EXIT        ;then do not reload
  126.  
  127.     ;set new vector
  128.         MOV    AX,0            ;re-address absolute 0
  129.         MOV    ES,AX
  130.         MOV    WORD PTR ES:INTERRUPT_77H,OFFSET INTERRUPT_CODE
  131.         MOV    WORD PTR ES:INTERRUPT_77H+2,CS
  132.  
  133.         STI                ;interrupts ok now
  134.  
  135. ;        LEA    DX,CS:INTERRUPT_END    ;point to end of intrpt code
  136. ;        MOV    CL,4            ;convert bytes to paragraphs
  137. ;        SHR    DX,CL
  138. ;        INC    DX            ;round up
  139.         MOV    DX,SYSPARM_LENGTH    ;this works better
  140.         SUB    AL,AL
  141.         MOV    AH,31H
  142.         INT    21H            ;exit and stay resident
  143.  
  144.     ;exit if SYSPARM has already been loaded.
  145. EARLY_EXIT:
  146.         RET                ;return to DOS        
  147.  
  148. SYSPARM_LOAD    ENDP
  149.  
  150.  
  151. CODE        ENDS
  152.         END    ENTRY_POINT        ;point IP to first instruction
  153.