home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Assembly / DSKPATCH.ASM < prev    next >
Assembly Source File  |  1986-10-07  |  5KB  |  140 lines

  1. CGROUP    GROUP    CODE_SEG, DATA_SEG
  2.     ASSUME    CS:CGROUP, DS:CGROUP
  3.  
  4.  
  5. ;-----------------------------------------------------------------------;
  6. ; This file contains the main program, along with most of the variables    ;
  7. ; for Dskpatch.                                ;
  8. ;-----------------------------------------------------------------------;
  9.  
  10.  
  11. ;-----------------------------------------------------------------------;
  12. ; We've declared a "dummy" copy of the code segment here to ensure that    ;
  13. ; all versions of the Macro Assembler will load the CODE_SEG into    ;
  14. ; memory before the DATA_SEG.  See Appendix C of Peter Norton's        ;
  15. ; Assembly Language Book for more information.                ;
  16. ;-----------------------------------------------------------------------;
  17. CODE_SEG    SEGMENT PUBLIC
  18. CODE_SEG    ENDS
  19.  
  20.  
  21. DATA_SEG    SEGMENT PUBLIC
  22.  
  23.     PUBLIC    SECTOR
  24. ;-----------------------------------------------;
  25. ; The entire sector (512 bytes) is stored in    ;
  26. ; this part of memory.  Since some hard disks    ;
  27. ; use very large sectors, we reserve 8192 bytes    ;
  28. ; here, but Dskpatch only works with 512 bytes.    ;
  29. ;-----------------------------------------------;
  30. SECTOR    DB    8192 DUP (0)
  31.  
  32.     PUBLIC    SECTOR_OFFSET
  33. ;-----------------------------------------------;
  34. ; SECTOR_OFFSET is the offset of the half-    ;
  35. ; sector display into the full sector.  It must    ;
  36. ; be a multiple of 16, and not greater than 256    ;
  37. ;-----------------------------------------------;
  38. SECTOR_OFFSET    DW    0
  39.  
  40.     PUBLIC    CURRENT_SECTOR_NO, DISK_DRIVE_NO
  41. CURRENT_SECTOR_NO    DW    0        ;Initially sector 0
  42. DISK_DRIVE_NO        DB    0        ;Initially Drive A:
  43.  
  44.  
  45.     PUBLIC    FILE_FLAG, FILE_HANDLE, FILE_NAME
  46.     PUBLIC    FILE_NAME_STRING
  47.     PUBLIC    STRING_LENGTH, LENGTH_READ
  48. ;-----------------------------------------------;
  49. ; FILE_FLAG is 0 for absolute sector reads and    ;
  50. ; writes.  When it's 1, reads and writes are    ;
  51. ; for sectors within a file.  Then         ;
  52. ; SECTOR_OFFSET is the relative sector within    ;
  53. ; the file.                    ;
  54. ;-----------------------------------------------;
  55. FILE_FLAG    DB    0            ;Initially absolute sectors
  56. FILE_HANDLE    DW    0            ;Handle of the opened file
  57.  
  58. FILE_NAME_STRING    LABEL    BYTE
  59. STRING_LENGTH    DB    80            ;Read up to 80 characters
  60. LENGTH_READ    DB    ?            ;Number of characters read
  61. FILE_NAME    DB    80 DUP (' ')        ;Name of file being looked at
  62.  
  63.  
  64.     PUBLIC    LINES_BEFORE_SECTOR, HEADER_LINE_NO
  65.     PUBLIC    HEADER_PART_1, HEADER_PART_2, FILE_HEADER
  66. ;-----------------------------------------------;
  67. ; LINES_BEFORE_SECTOR is the number of lines    ;
  68. ; at the top of the screen before the half-    ;
  69. ; sector display.                ;
  70. ;-----------------------------------------------;
  71. LINES_BEFORE_SECTOR    DB    2
  72. HEADER_LINE_NO        DB    0
  73.  
  74. HEADER_PART_1        DB    'Disk ',0
  75. HEADER_PART_2        DB    '         Sector ',0
  76. FILE_HEADER        DB    '      From start of: ',0
  77.  
  78.     PUBLIC    PROMPT_LINE_NO, EDITOR_PROMPT, DISK_PROMPT
  79.     PUBLIC    SECTOR_PROMPT, FILE_NAME_PROMPT, OFFSET_PROMPT
  80. PROMPT_LINE_NO        DB    21
  81. EDITOR_PROMPT        DB    'Press function key, or enter'
  82.             DB    ' character or hex byte: ',0
  83. DISK_PROMPT        DB    'Enter letter for disk drive: ',0
  84. SECTOR_PROMPT        DB    'Enter sector dumber (decimal) to read: ',0
  85. FILE_NAME_PROMPT    DB    'Enter file name: ',0
  86. OFFSET_PROMPT        DB    'Enter offset from start of file: ',0
  87.  
  88.     PUBLIC    FUNCTION_KEY_LINE_NO, FUNCTION_KEY_LINE
  89. FUNCTION_KEY_LINE_NO    DB    24
  90. FUNCTION_KEY_LINE    DB    '1Prev.', 2 DUP(' ')
  91.             DB    '2Next', 3 DUP(' ')
  92.             DB    '3Drive', 2 DUP(' ')
  93.             DB    '4Sector',' '
  94.             DB    '5',24,'Save',2 DUP(' ')
  95.             DB    '6File', 3 DUP(' ')
  96.             DB    '7Offset', ' '
  97.             DB    '8', 7 DUP(' ')
  98.             DB    '9', 7 DUP(' ')
  99.             DB    '0Exit', 2 DUP(' ')
  100.             DB    0
  101.     PUBLIC    ERROR_MESSAGE_LINE_NO
  102. ERROR_MESSAGE_LINE_NO    DB    23
  103. DATA_SEG    ENDS
  104.  
  105.  
  106. CODE_SEG    SEGMENT PUBLIC
  107.     ORG    100H
  108.  
  109.     EXTRN    CLEAR_SCREEN:NEAR, INIT_SEC_DISP:NEAR
  110.     EXTRN    WRITE_PROMPT_LINE:NEAR, DISPATCHER:NEAR
  111.     EXTRN    WRITE_FUNCTION_KEYS:NEAR
  112.     EXTRN    GOTO_XY:NEAR, CLEAR_TO_END_OF_LINE:NEAR
  113.     EXTRN    INIT_DISK:NEAR
  114.     EXTRN    WRITE_EDITOR_PROMPT:NEAR
  115. ;-----------------------------------------------------------------------;
  116. ; Here is the main program for Dskpatch.  As you can see, this        ;
  117. ; procedure is mostly calls to other procedures.            ;
  118. ;-----------------------------------------------------------------------;
  119. DISK_PATCH    PROC    FAR
  120.     CALL    CLEAR_SCREEN        ;Clear the entire screen
  121.     CALL    INIT_DISK        ;Setup the disk information
  122.     CALL    WRITE_FUNCTION_KEYS    ;Display the function-key line
  123.     CALL    INIT_SEC_DISP        ;Display the first part of this sector
  124.     CALL    WRITE_EDITOR_PROMPT    ;Display the Edit prompt
  125.  
  126.     CALL    DISPATCHER        ;Let the dispatcher do all the work
  127.  
  128.     XOR    DL,DL            ;Place cursor at bottom of screen
  129.     MOV    DH,24
  130.     CALL    GOTO_XY
  131.     CALL    CLEAR_TO_END_OF_LINE    ;Clear the inverse video key line
  132.     MOV    DH,23
  133.     CALL    GOTO_XY            ;And leave cursor on line 23
  134.     INT    20H            ;Exit back to DOS
  135. DISK_PATCH    ENDP
  136.  
  137. CODE_SEG    ENDS
  138.  
  139.     END    DISK_PATCH
  140.