home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 165 / MOREDISK.ZIP / CHG10.ASM next >
Assembly Source File  |  1986-07-28  |  6KB  |  126 lines

  1.             page    ,132
  2. cseg        segment
  3.             assume  cs:cseg,ds:cseg,es:cseg
  4.             org     100h
  5. start:      jmp     chg10  
  6.  
  7. opt_char    equ     'M'                    ; MODIFY option character
  8. slash       equ     '/'
  9. opt_flag    db      0                      ; Option flag storage
  10.  
  11. mod_tbl     dw      08h                    ; Original Clusters per sector
  12.             dw      08h                    ; Original Sectors in FAT
  13.             dw      04h                    ; Modified Clusters per sector
  14.             dw      15h                    ; Modified Sectors in FAT
  15.  
  16. ok_msg      db      0Ah,' : Altered--re-boot, re-format, and reload!',0Dh,0Ah,'$'
  17. form_msg    db      'Format: CHG10 d: /{M|R}',0Dh,0Ah,'$'
  18. test1_msg   db      'Sectors in FAT: $'
  19. test2_msg   db      'Sectors per Cluster: $'
  20. test_msgs   dw      test2_msg
  21.             dw      test1_msg
  22. error_msg   db      'Expected '
  23. expected    dw      ?
  24.             db      ', Found '
  25. found       dw      ?
  26.             db      0Dh,0Ah,'$'
  27.  
  28. chg10       proc    near
  29.             mov     dl,byte ptr ds:[5Ch]   ; Get drive id
  30.             cmp     dl,3d                  ; If drive id < 3,
  31.             jl      form_error             ;   then show correct form
  32.             mov     si,2d                  ; Offset for original FAT
  33.             call    miniopt                ; Check for "M" option
  34.             je      read_boot              ; If found, read boot record
  35.             mov     al,byte ptr [di]       ; Get other option
  36.             and     al,5Fh                 ; Insure uppercase
  37.             cmp     al,'R'                 ; If not "R" option
  38.             jne     form_error             ;   then show correct form
  39.             mov     si,6d                  ; Offset for modified FAT
  40. ; Read boot record
  41. read_boot:  mov     bx,offset alt_dta      ; ES:BX=> alternate DTA
  42.             mov     cx,0001h               ; Cylinder/sector number
  43.             mov     dh,01h                 ; Specify head 1
  44.             add     dl,7Dh                 ; Compute drive number
  45.             mov     ax,0201h               ; Read 1 sector
  46.             int     13h                    ; *
  47. ; Validate changes
  48.             mov     ax,[bx+16h]            ; Get current FAT sectors
  49.             cmp     ax,[mod_tbl+si]        ; If not correct,
  50.             jne     error                  ;   then error off
  51.             sub     si,2d                  ; Adjust for Clusters
  52.             mov     al,[bx+0Dh]            ; Get current cluster count
  53.             cmp     al,byte ptr [mod_tbl+si] ; If not correct,
  54.             jne     error                  ;   then error off
  55. ; Modify values in DTA and re-write boot record
  56.             xor     si,6d                  ; Modify pointer for changes
  57.             add     si,offset mod_tbl      ; *
  58.             std                            ; Decrement pointer (SI)
  59.             lodsw                          ; Get new FAT value
  60.             mov     [bx+16h],ax            ; Put in DTA
  61.             lodsw                          ; Get new cluster value
  62.             mov     byte ptr [bx+0Dh],al   ; Put in DTA
  63.             mov     ax,0301h               ; Write DTA back as boot record
  64.             int     13h                    ; *
  65.             mov     al,byte ptr ds:[5Ch]   ; Get drive id
  66.             or      al,40h                 ; Convert to character
  67.             mov     ok_msg+1,al            ; Modify message
  68.             mov     dx,offset ok_msg       ; Tell user disk modified
  69.             mov     ah,09h                 ; *
  70.             int     21h                    ; *
  71.             int     20h                    ; End of program
  72.  
  73. form_error: mov     dx,offset form_msg     ; Show correct format
  74.             mov     ah,09h                 ; *
  75.             int     21h                    ; *
  76.             int     20h                    ; Terminate program
  77.  
  78. error:      push    ax                     ; Save value found
  79.             push    si                     ; Save pointer
  80.             and     si,2d                  ; Convert to word pointer
  81.             mov     dx,[test_msgs+si]      ; Get correct message to display
  82.             mov     ah,09h                 ; Display string
  83.             int     21h                    ; *
  84.             pop     si                     ; Restore registers
  85.             pop     ax                     ; *
  86.             call    dec2asc                ; Convert AX to decimal
  87.             mov     found,ax               ; Put in message
  88.             mov     ax,[mod_tbl+si]        ; Get expected value
  89.             call    dec2asc                ; Convert to decimal
  90.             mov     expected,ax            ; Put in message
  91.             mov     dx,offset error_msg    ; Show what happened
  92.             mov     ah,09h                 ; *
  93.             int     21h                    ; *
  94.             int     20h                    ; *
  95. chg10       endp
  96.  
  97. miniopt     proc    near
  98.             cld                            ; Insure forward scan
  99.             mov     al,slash               ; Search for option start
  100.             xor     ch,ch                  ; Clear upper CX
  101.             mov     cl,ds:[80h]            ; Get character count
  102.             jcxz    set_zf                 ; Exit if no option
  103.             mov     di,81h                 ; ES:DI=> comline
  104.             repne   scasb                  ; Search for option
  105.             jnz     mo_exit                ; Exit if no option
  106.             mov     al,byte ptr [di]       ; Get option
  107.             and     al,5Fh                 ; Insure uppercase
  108. set_zf:     cmp     al,opt_char            ; If correct option, set ZF
  109. mo_exit:    ret                            ; Exit routine
  110. miniopt     endp
  111.  
  112. ; DEC2ASC--converts binary value (AL) into two digit, base 10, ASCII
  113. ;          format number (AX).  (Number assumed < 100.)
  114. dec2asc     proc    near
  115.             xor     ah,ah                  ; Clear for division
  116.             mov     cl,10d                 ; Isolate ten's and one's
  117.             div     cl                     ;   with division by 10
  118.             or      ax,3030h               ; Convert to ASCII
  119.             ret                            ; Return to caller
  120. dec2asc     endp
  121.  
  122. alt_dta     label   byte                   ; First byte of alternate DTA
  123.  
  124. cseg        ends
  125.             end     start
  126.