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

  1. TITLE    ASK0    1-10-85    [4-19-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    100H
  12.  
  13. Ask1    proc    near
  14.     CALL    Check_CmdLine    ;check command line for prompt, display
  15.     CALL    GetChar        ;get user key (Y or N)
  16.     MOV    AH,4CH        ;terminate, Errorlevel in AL
  17.     INT    21H
  18. Ask1    endp
  19.  
  20. Check_CmdLine    proc    near
  21.     MOV    CL,24H    ;'$'
  22.     MOV    DI,80H            ;check cmd line
  23.     MOV    DX,[DI]            ;snarf length byte
  24.     xor    dh,dh            ;clear msb
  25.     or    dx,dx            ;anything there?
  26.     JZ    Prompt_12E        ;nope, go prompt him
  27.     CMP    DX,3CH            ;60 chars?
  28.     JZ    Prompt_12E        ; yep, go prompt him
  29.     ADD    DX,80H            ;+128 into code space
  30.     MOV    SI,DX            ;pointer
  31.     INC    SI            ;bump
  32.     MOV    [SI],CL            ;stuff terminating '$'
  33.     MOV    DX,82H            ;cmd line first char
  34.     MOV    AH,9            ;display string
  35.     INT    21H
  36.     ret                ;done
  37. Check_CmdLine    endp
  38.  
  39. Prompt_12E    proc    near
  40.     MOV    DX,OFFSET pressYNPrompt    ;'Press Y or N'
  41.     MOV    AH,9            ;display string
  42.     INT    21H
  43.     RET
  44. Prompt_12E    endp
  45.  
  46. GetChar    proc    near
  47.     mov    ax,0C07H        ;clear kbd,
  48.     INT    21H            ; do direct kbd input w/o echo
  49.     xor    bx,bx            ;assume yes, Errorlevel = 0
  50.     CMP    AL,'Y'            ;answered yes?
  51.     JZ    Show_Response        ; ok
  52.     CMP    AL,'y'            ;answered yes?
  53.     JZ    Show_Response        ; ok
  54.     inc    bx            ;assume no, Errorlevel = 1
  55.     CMP    AL,'N'            ;answered no?
  56. ;    JZ    L0162            ; ok
  57.     je    Show_Response        ; ok
  58.     CMP    AL,'n'            ;answered no?
  59. ;    JZ    L0162            ; ok
  60.     je    Show_Response        ; ok
  61.     MOV    DX,OFFSET ynPrompt    ;dummy .. 'Y or N' prompt
  62.     MOV    AH,9            ;display string
  63.     INT    21H
  64.     JMP    SHORT    GetChar        ; and try again
  65.  
  66. Show_Response:
  67.     MOV    response,AL        ;stuff char in string
  68.     MOV    DX,OFFSET response    ;display char, newline
  69.     MOV    AH,9            ;display string
  70.     INT    21H
  71.     MOV    AL,bl            ;return Errorlevel = whatever
  72.     RET
  73.  
  74. ;L0162:    MOV    response,AL        ;stuff char in string
  75. ;    MOV    DX,OFFSET response    ;display char, new line
  76. ;    MOV    AH,9            ;display string
  77. ;    INT    21H
  78. ;    MOV    AL,1            ;return Errorlevel = 1
  79. ;    RET
  80.  
  81. ynPrompt    DB    CR,LF,'(Y/N) ? $'
  82. pressYNPrompt    DB    'Press Y or N ? $'
  83. response    DB    ' ',CR,LF,'$'
  84.  
  85. GetChar    endp
  86.  
  87.     CodeSeg    ENDS
  88.     END    Ask1
  89.