题目是:输入一个字符串,统计输入的字符串中字母、数字以及其他字符各有多少个。
汇编的时候没有报错,链接的时候报以下错误:
Invalid keyboard code specified
Microsoft (R) Overlay Linker Version 3.60
Copyright (C) Microsoft Corp 1983-1987. All rights reserved.
LINK : warning L4021: no stack segment
LINK : warning L2029: Unresolved externals:
READHEX in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
READINT in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
CRLF in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
WRITEDEC in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
WRITECR in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
READDEC in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
WRITEHEX in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
WRITEINT in file(s):
D:/EXAMPLE/WORK412.OBJ(D:/example/work412.asm)
There were 8 errors detected
我的源文件是:
include ylib.h
data segment
buffer db 101,?,101 dup(?)
mess db 0ah,0dh,"Input a string please:$"
outmsg1 db 0ah,0dh,"char:$"
outmsg2 db 0ah,0dh,"number:$"
outmsg3 db 0ah,0dh,"others:$"
char db ?
num db ?
other db ?
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
lea dx,mess
mov ah,09h
int 21h ;输入提示信息
mov ah,0ah
lea dx,buffer
int 21h ;输入字符串
call crlf
mov cl,buffer+1
mov ch,0
lea bx,buffer+1
mov char,0
mov byte ptr num,0
one: cmp cx,0
je over
inc bx
dec cx
cmp byte ptr[bx],30h
jb one
je two
cmp byte ptr[bx],39h
jc there
two: inc num
jmp one
there: cmp byte ptr[bx],41h
jb one
je four
cmp byte ptr[bx],5ah
jc five
four: inc char
jmp one
five: cmp byte ptr[bx],61h
jb one
je six
cmp byte ptr[bx],7ah
jc one
six: inc char
jmp one
over: mov al,other
mov al,buffer+1
sub al,char
sub al,num
mov other,al
mov al,char
mov ah,0
lea dx,outmsg1
call writeint
mov al,num
lea dx,outmsg2
call writeint
mov al,other
lea dx,outmsg3
call writeint
mov ax,4c00h
int 21h
code ends
end start
请路过的高手指点一二。