⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosgetch.asm

📁 c语言库函数!里面包含了所以c语言中的系统函数的实现及其详细说明和代码!请大家及时下载!
💻 ASM
字号:
;  +++Date last modified: 05-Jul-1997

        page    55, 132

;  FUNCTIONS: dosgetch/doswaitch
;
;  Donated to the public domain 96-11-12 by Tom Torfs (2:292/516)
;
;  dosgetch() attempts to read a character from stdin. Returns the
;  character read or EOF (-1) if no character is available. Extended keys
;  are returned in two parts: first a zero and then the actual code.
;
;  doswaitch() works alike but waits if no character is available.
;
;  Requires MASM 5.1 or later or equivalent
;
;  Assemble with:       MASM /Mx /z ...
;                       TASM /jMASM /mx /z ...
;

%       .MODEL  memodel,C               ;Add model support via
                                        ;command line macros, e.g.
                                        ;MASM /Dmemodel=LARGE

        .CODE
;
; int dosgetch(void) - comments see above
;

        PUBLIC  dosgetch

dosgetch        PROC

        push dx
        mov     ah, 6                   ; direct console I/O
        mov     dl, 255                 ; read a character
        int     21h                     ; let DOS do the job
        pop dx

        jz      nochar                  ; character ready ?

        xor     ah,ah                   ; clear high byte ax
        ret                             ; return

nochar:

        mov     ax, -1                  ; return EOF
        ret                             ; return

dosgetch        ENDP    

;
; int doswaitch(void) - comments see above
;

        PUBLIC  doswaitch

doswaitch       PROC

waitloop:

        call    dosgetch               ; try to read character
        
        cmp     ax, -1                 ; available ?
        je waitloop                    ; no -> repeat

        ret                            ; return

doswaitch       ENDP    

        end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -