home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Assembly / DISK_I19.ASM < prev    next >
Assembly Source File  |  1986-09-25  |  3KB  |  103 lines

  1. CGROUP    GROUP    CODE_SEG, DATA_SEG
  2.     ASSUME    CS:CGROUP, DS:CGROUP
  3.  
  4.  
  5. CODE_SEG    SEGMENT PUBLIC
  6.  
  7.     PUBLIC    PREVIOUS_SECTOR
  8.     EXTRN    INIT_SEC_DISP:NEAR, WRITE_HEADER:NEAR
  9.     EXTRN    WRITE_PROMPT_LINE:NEAR
  10. DATA_SEG    SEGMENT PUBLIC
  11.     EXTRN    CURRENT_SECTOR_NO:WORD, EDITOR_PROMPT:BYTE
  12. DATA_SEG    ENDS
  13. ;-----------------------------------------------------------------------;
  14. ; This procedure reads the previous sector, if possible.        ;
  15. ;                                    ;
  16. ; Uses:        WRITE_HEADER, READ_SECTOR, INIT_SEC_DISP        ;
  17. ;        WRITE_PROMPT_LINE                    ;
  18. ; Reads:    CURRENT_SECTOR_NO, EDITOR_PROMPT            ;
  19. ; Writes:    CURRENT_SECTOR_NO                    ;
  20. ;-----------------------------------------------------------------------;
  21. PREVIOUS_SECTOR        PROC    NEAR
  22.     PUSH    AX
  23.     PUSH    DX
  24.     MOV    AX,CURRENT_SECTOR_NO    ;Get current sector number
  25.     OR    AX,AX            ;Don't decrement if already 0
  26.     JZ    DONT_DECREMENT_SECTOR
  27.     DEC    AX
  28.     MOV    CURRENT_SECTOR_NO,AX    ;Save new sector number
  29.     CALL    WRITE_HEADER
  30.     CALL    READ_SECTOR
  31.     CALL    INIT_SEC_DISP        ;Dispaly new sector
  32.     LEA    DX,EDITOR_PROMPT
  33.     CALL    WRITE_PROMPT_LINE
  34. DONT_DECREMENT_SECTOR:
  35.     POP    DX
  36.     POP    AX
  37.     RET
  38. PREVIOUS_SECTOR        ENDP
  39.     PUBLIC    NEXT_SECTOR
  40.     EXTRN    INIT_SEC_DISP:NEAR, WRITE_HEADER:NEAR
  41.     EXTRN    WRITE_PROMPT_LINE:NEAR
  42. DATA_SEG    SEGMENT PUBLIC
  43.     EXTRN    CURRENT_SECTOR_NO:WORD, EDITOR_PROMPT:BYTE
  44. DATA_SEG    ENDS
  45. ;-----------------------------------------------------------------------;
  46. ; Reads the next sector.                        ;
  47. ;                                    ;
  48. ; Uses:        WRITE_HEADER, READ_SECTOR, INIT_SEC_DISP        ;
  49. ;        WRITE_PROMPT_LINE                    ;
  50. ; Reads:    CURRENT_SECTOR_NO, EDITOR_PROMPT            ;
  51. ; Writes:    CURRENT_SECTOR_NO                    ;
  52. ;-----------------------------------------------------------------------;
  53. NEXT_SECTOR    PROC    NEAR
  54.     PUSH    AX
  55.     PUSH    DX
  56.     MOV    AX,CURRENT_SECTOR_NO
  57.     INC    AX            ;Move to next sector
  58.     MOV    CURRENT_SECTOR_NO,AX
  59.     CALL    WRITE_HEADER
  60.     CALL    READ_SECTOR
  61.     CALL    INIT_SEC_DISP        ;Display new sector
  62.     LEA    DX,EDITOR_PROMPT
  63.     CALL    WRITE_PROMPT_LINE
  64.     POP    DX
  65.     POP    AX
  66.     RET
  67. NEXT_SECTOR    ENDP
  68.  
  69.  
  70.     PUBLIC    READ_SECTOR
  71. DATA_SEG    SEGMENT PUBLIC
  72.     EXTRN    SECTOR:BYTE
  73.     EXTRN    DISK_DRIVE_NO:BYTE
  74.     EXTRN    CURRENT_SECTOR_NO:WORD
  75. DATA_SEG    ENDS
  76. ;-----------------------------------------------------------------------;
  77. ; This procedure reads one sector (512 bytes) into SECTOR.        ;
  78. ;                                    ;
  79. ; Reads:    CURRENT_SECTOR_NO, DISK_DRIVE_NO            ;
  80. ; Writes:    SECTOR                            ;
  81. ;-----------------------------------------------------------------------;
  82. READ_SECTOR    PROC    NEAR
  83.     PUSH    AX
  84.     PUSH    BX
  85.     PUSH    CX
  86.     PUSH    DX
  87.     MOV    AL,DISK_DRIVE_NO    ;Drive number
  88.     MOV    CX,1            ;Read only 1 sector
  89.     MOV    DX,CURRENT_SECTOR_NO    ;Logical sector number
  90.     LEA    BX,SECTOR        ;Where to store this sector
  91.     INT    25h            ;Read the sector
  92.     POPF                ;Discard flags put on stack by DOS
  93.     POP    DX
  94.     POP    CX
  95.     POP    BX
  96.     POP    AX
  97.     RET
  98. READ_SECTOR    ENDP
  99.  
  100. CODE_SEG    ENDS
  101.  
  102.     END
  103.