home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / batch / library / batutl2 / dsize.asm < prev    next >
Assembly Source File  |  1988-04-20  |  3KB  |  111 lines

  1. TITLE    DSIZE    1-19-85    [4-16-88]
  2. ;Toad Hall Disassembly, tweak
  3.  
  4. LF    EQU    0AH
  5. CR    EQU    0DH
  6. ;
  7. ;INITIAL VALUES :    CS:IP    0000:0100
  8. ;            SS:SP    0000:FFFF
  9. CodeSeg    SEGMENT
  10.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  11.     ORG 5CH
  12. curdrive    db    ?
  13.  
  14.     ORG    100H
  15.  
  16. Dsize    proc    near
  17.     CMP    AL,0FFH            ;No current drive?
  18.     JNZ    ChkDos            ; nope, continue
  19.      MOV    DX,OFFSET BadDrvMsg    ;'Invalid drive specifier'
  20.      jmp    short Die
  21.  
  22. ChkDos:    MOV    AH,30H            ;Get Dos version
  23.     INT    21H
  24.     or    al,al            ;TH major version (0 if <2.0)
  25.     JNZ    GetSpecs        ; nope, keep going
  26.      MOV    DX,OFFSET Dos2Msg    ;'Dos 2.0 or higher'
  27.      jmp    short Die
  28.  
  29. GetSpecs:
  30. ;    MOV    DL,DS:5CH        ;current drive
  31.     mov    dl,curdrive        ;current drive val in PSP
  32.     MOV    AH,36H            ;get drive specs
  33.     INT    21H
  34.     mov    ax,offset Terminate    ;this is Soooo bad...
  35.     push    ax            ; .. but I love it!
  36.     mov    al,4            ;assume Errorlevel 4
  37.     CMP    DX,0162H        ;360Kb?
  38.     JNZ    Chk320            ; Nope
  39.      MOV    DX,OFFSET K360Msg    ;'360K disk'
  40. ;     jmp    short Terminate
  41.      ret                ;to Terminate
  42.  
  43. Chk320:    dec    al            ;assume Errorlevel 3
  44.     CMP    DX,013BH        ;320Kb?
  45.     JNZ    Chk180            ; nope
  46.      MOV    DX,OFFSET K320Msg    ;'320K disk'
  47. ;     jmp    short Terminate
  48.      ret                ;to Terminate
  49.  
  50. Chk180:    dec    al            ;assume Errorlevel 2
  51.     CMP    DX,015FH        ;180Kb?
  52.     JNZ    Chk160            ; Nope
  53.      MOV    DX,OFFSET K180Msg    ;'180K disk'
  54. ;     jmp    short Terminate
  55.      ret                ;to Terminate
  56.  
  57. Chk160:    dec    al            ;assume Errorlevel 1
  58.     CMP    DX,0139H        ;160Kb?
  59.     JNZ    Unknown            ; nope
  60.      MOV    DX,OFFSET K160Msg    ;'160K disk'
  61. ;     jmp    short Terminate
  62.      ret                ;to Terminate
  63. Unknown:
  64.     xor    al,al            ;return Errorlevel 0
  65.     MOV    DX,OFFSET UnkMsg    ;'Unrecognized..'
  66.     pop    bx            ;clear the pushed return address
  67.  
  68. Terminate:
  69.     mov    bx,ax            ;save Errorlevel (AL) in bx
  70.     call    Display            ;CrLf, string in DX, CrLf
  71.     mov    ax,bx            ;restore AL Errorlevel
  72.     MOV    AH,4CH            ;terminate process
  73.     INT    21H            ;exit
  74.  
  75. Die:    call    Display            ;CrLf, string in DX, CrLf
  76.     INT    20H            ;program terminate
  77.  
  78. Display:
  79.     mov    di,dx            ;save string offset
  80.     mov    dx,offset CrLf
  81.     mov    si,dx            ;save CrLf offset
  82.     mov    ah,9            ;display string
  83.     int    21H
  84.     mov    dx,di            ;restore string offset
  85.     int    21H            ;AH is still 9
  86.     mov    dx,si            ;restore CrLf offset
  87.     int    21H            ;do terminating CrLf
  88.     int    21H            ;wants 2 of them
  89.     ret
  90.  
  91. K360Msg    DB    '360K disk$'
  92.  
  93. K180Msg    DB    '180K disk$'
  94.  
  95. K320Msg    DB    '320K disk$'
  96.  
  97. K160Msg    DB    '160K disk$'
  98.  
  99. UnkMsg        DB    7,'Unrecognized disk format$'
  100.  
  101. BadDrvMsg    DB    7,'Invalid drive specifier!$'
  102.  
  103. Dos2Msg        db    7,'This utility only works with '
  104.         db    'DOS 2.0 or higher!$'
  105.  
  106. CrLf        db    CR,LF,'$'
  107. Dsize    endp
  108.  
  109.     CodeSeg    ENDS
  110.     END    Dsize
  111.