21,459
社区成员
发帖
与我相关
我的任务
分享
DATA SEGMENT
ISNUM DB “It is a numeral.$”
NONUM DB “Mistake,it is not a numeral.$”
DAT ENDS
MYCD SEGMENT
ASSUME CS:MYCD,DS:DAT
FFD PROC FAR
START:MOV AX,DAT
MOV DS,AX
MOV AH,1
INT 21H
CMP AL,‘0’
____________ jb GO
CMP AL,‘9’
_____________ ja GO
_____________ mov dx,offset ISNUM
MOV AH,9
INT 21H
DONE: MOV AH,4CH
INT 21H
GO: _______________ mov dx,offset NONUM
MOV AH,9
INT 21H
JMP DONE
FFD ENDP
MYCD ENDS
END START
;判断从键盘输入的是什么字符
;KEYBOARD INPUT WITH ECHO (01H)
;keycode.asm
;ml /c keycode.asm
;link16 /TINY keycode;
code segment public
assume cs:code,ds:code
org 100h
start: jmp begin
msg1 db ' Press any key to test,Ctrl-Z to end.',0dh,0ah,'$'
msg2 db ' Letter ',0dh,0ah,'$'
msg3 db ' Extended Ascii Character ',0dh,0ah,'$'
msg4 db ' Digital ',13,10,'$'
begin: mov ax,cs
mov ds,ax
mov dx,offset msg1 ;set up to display message
mov ah,09h ;display string function request
int 21h ;call DOS
next:
mov ah,01h ;read keyboard and echo function request
int 21h ;call DOS
mov cx,offset msg2 ;set up to display message
cmp al,0 ;check if extended ascii char
jne disp ;no, tack jump
mov ah,01h ;read keyboard and echo function request
int 21h ;call DOS
mov cx,offset msg3
disp:
cmp al,1ah ;check for control-z
je done ;quit if control-z
cmp al,'0'
jl noNumber;
cmp al,'9'
jg noNumber;
;显示输入的字符:
mov dl,al ;return char in dl for next function
mov ah,02h ;display character funct request
int 21h ;call DOS
mov dx,offset msg4 ;get proper message
mov ah,09h ;display string function request
int 21h ;call DOS
jmp next
noNumber:
;显示输入的字符:
mov dl,al ;return char in dl for next function
mov ah,02h ;display character funct request
int 21h ;call DOS
mov dx,cx ;get proper message
mov ah,09h ;display string function request
int 21h ;call DOS
jmp next ;get next character
done:
mov ah,00h ;terminate progream funct request
int 21h ;call DOS
code ends ;end of code segment
end start ;start is the entry point