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

  1. TITLE    GETDIGIT    12-13-83    [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.  
  10. CodeSeg    SEGMENT
  11.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  12.     ORG    100H
  13.  
  14. GetDigit    proc    near
  15.     MOV    AH,30H        ;get DOS version
  16.     INT    21H
  17.     or    al,al        ;2.0 or above?
  18.     jz    WrongDos    ; yep
  19.  
  20. ;L010B:
  21.     XOR    CX,CX
  22.     MOV    SI,80H        ;DOS's PSP cmd line
  23.     MOV    CL,[SI]
  24.     or    cl,cl        ;anything there (length byte)
  25.     JZ    Lup127        ; nope, go check for kbd input
  26.     DEC    CL        ;adjust cmd line length
  27.     MOV    SI,82H        ;snarf first char
  28.  
  29. Lup11E:    MOV    DL,[SI]        ;snarf cmd line char
  30.     MOV    AH,2        ;display output
  31.     INT    21H
  32.     INC    SI        ;next cmd line char
  33.     LOOP    Lup11E
  34.  
  35. Lup127:    MOV    AX,0C07H    ;Clear kbd, do function 7 (kbd input w/o echo)
  36.     INT    21H
  37.     or    al,al        ;zero? (nonzero means ASCII char)
  38.     JNZ    GotChar        ; nonzero, check for digit
  39.                 ;probably special char, snarf next char
  40.      MOV    AH,7        ;direct kbd input w/o echo
  41.      INT    21H
  42.      JMP    SHORT    Lup127    ;and go back for more
  43.  
  44. GotChar:CMP    AL,'0'
  45.     JB    Lup127            ;below 0, discard, reloop
  46.     CMP    AL,'9'
  47.     JA    Lup127            ;above 9, discard, reloop
  48.     PUSH    AX            ;save the digit
  49.     MOV    DL,AL            ;display it
  50.     MOV    AH,2            ;display output
  51.     INT    21H
  52.     POP    AX            ;restore digit
  53.     SUB    AL,30H            ;de-ascify
  54.     MOV    AH,4CH            ;Terminate process
  55.     INT    21H
  56.  
  57. WrongDos:
  58.     mov    dx,offset Dos2Msg
  59.     MOV    AH,9            ;display string
  60.     INT    21H
  61.     XOR    AX,AX            ;return Errorlevel=0
  62.     INT    21H            ;terminate
  63.  
  64. Dos2Msg    DB    'GETDIGIT requires DOS 2.0 or greater.',CR,LF
  65.     DB    '$'
  66. ;    DB    'GETDIGIT -- Copyright (C) 1983 Tony Alan Rhea'
  67. GetDigit    endp
  68.  
  69.     CodeSeg    ENDS
  70.     END    GetDigit
  71.