汇编语言实验题:分类统计字符个数,出现问题,急需解决!!!

Niko_wq 2011-06-19 05:54:05
;这是我写的代码,个人认为没有错误,但出来的结果是错的!希望高手能帮我解决
;*********************************************************************
data segment
string1 label byte
max1 db 80
act1 db ?
str1 db 80 dup(?)
numbers db ?
letters db ?
others db ?
mess1 db 'The numbers of number:','$'
mess2 db 'The numbers of letter:','$'
mess3 db 'The numbers of others:','$'
mess4 db 13,10,'$'
mess5 db 'Enter Sentence:',13,10,'$'
data ends
;*********************************************************************
code segment
main proc far
assume cs:code,ds:data,es:data

start: push ds
sub ax,ax
push ax

mov ax,data
mov ds,ax
mov es,ax

mov numbers,0
mov letters,0
mov others,0
mov ch,act1

lea dx,mess5
mov ah,09h
int 21h
lea dx,string1
mov ah,0ah
int 21h
lea dx,mess4
mov ah,09h
int 21h

lea si,str1
p5: mov dx,[si]
cmp dx,'0'
jl p1 ;dx<'0'
cmp dx,'9'
jle p2 ;'0'<=dx<='9'
cmp dx,'A'
jl p1 ;'9'<dx<'A'
cmp dx,'Z'
jle p3 ;'A'<=dx<='Z'
cmp dx,'a'
jl p1 ;'Z'<dx<'a'
cmp dx,'z'
jle p3 ;'a'<=dx<='z'
jmp p1 ;dx>'z'
p1: inc others ;bh中存放其他字符的个数
jmp p4
p2: inc numbers ;al中存放数字的个数
jmp p4
p3: inc letters ;bl中存放字母的个数
p4: inc si
dec ch
cmp ch,0
jnz p5
mov cl,4

p8: lea dx,mess1
mov ah,09h
int 21h
mov ch,2
jmp p7
p9: lea dx,mess2
mov ah,09h
int 21h
mov ch,2
jmp p12
p10: lea dx,mess3
mov ah,09h
int 21h
mov ch,2
jmp p13

p7: rol numbers,cl
mov bh,numbers
and bh,0fh
jmp p14
p12: rol letters,cl
mov bh,letters
and bh,0fh
jmp p16
p13: rol others,cl
mov bh,others
and bh,0fh
jmp p18

p14: add bh,30h
cmp bh,3ah
jb p15
add bh,07h
p15: mov dl,bh
mov ah,2
int 21h
dec ch
cmp ch,0
jnz p7
lea dx,mess4
mov ah,09h
int 21h
jmp p9

p16: add bh,30h
cmp bh,3ah
jb p17
add bh,07h
p17: mov dl,bh
mov ah,2
int 21h
dec ch
cmp ch,0
jnz p12
lea dx,mess4
mov ah,09h
int 21h
jmp p10

p18: add bh,30h
cmp bh,3ah
jb p19
add bh,07h
p19: mov dl,bh
mov ah,2
int 21h
dec ch
cmp ch,0
jnz p13
lea dx,mess4
mov ah,09h
int 21h
jmp exit
exit: ret
main endp
code ends
end start

此程序在编译和连接时都没有错误,只是结果有问题
运行结果如下:
Enter Sentence:
we are 123
按回车键出现如下结果:
The numbers of number:00
The numbers of letter:34
The numbers of others:FD
...全文
325 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
masmaster 2011-06-19
  • 打赏
  • 举报
回复
;
;This Program Compiled Sucess by Masm 6.15
;
assume cs:code,ds:data
data segment
msg db 'Enter a string:$'
buffer db 80,0,80 dup (0)
_number db 0
_cap db 0
_low db 0
_other db 0
nummsg db 'numbers of digit:$'
capmsg db 'numbers of cap-letter:$'
lowmsg db 'numbers of low-letter:$'
othmsg db 'numbers of other-char:$'
data ends
code segment
start:
mov ax,data
mov ds,ax

mov dx,offset msg
mov ah,9
int 21h

mov dx,offset buffer
mov ah,10
int 21h

call crlf

mov bx,offset buffer+2
mov cl,buffer+1
s:
mov al,[bx]
cmp al,'0'
jae sz
jmp oth
sz:
cmp al,'9'
jbe num
jmp zm
num:
inc _number
jmp jx
zm:
cmp al,'A'
jae zm0
jmp oth
zm0:
cmp al,'Z'
jbe zm1
jmp zm2
zm1:
inc _cap
jmp jx
zm2:
cmp al,'a'
jae zm3
jmp oth
zm3:
cmp al,'z'
jbe zm4
oth:
inc _other
jmp jx
zm4:
inc _low
jx:
inc bx
loop s


mov dx,offset nummsg
mov ah,9
int 21h

mov dl,_number
call disp

call crlf

mov dx,offset capmsg
mov ah,9
int 21h

mov dl,_cap
call disp

call crlf

mov dx,offset lowmsg
mov ah,9
int 21h

mov dl,_low
call disp

call crlf

mov dx,offset othmsg
mov ah,9
int 21h

mov dl,_other
call disp

mov ah,4ch
int 21h
;crlf
crlf proc uses ax dx
mov ah,2
mov dl,13
int 21h
mov dl,10
int 21h
ret
crlf endp
;
;input:dx
disp proc uses dx
mov ax,dx
xor dx,dx
mov bx,10
mov cx,0
d2: cmp ax,10
jb ok2
div bx
add dl,30h
push dx
xor dx,dx
inc cx
jmp d2
ok2: add al,30h
push ax
inc cx
d3: pop dx
mov ah,2
int 21h
loop d3
ret
disp endp
;
code ends
end start
内容概要:本文系统介绍了基于核主成分分析(KPCA)的故障检测方法,重点实现了T²和Q统计指数的可视化,并提供了完整的Matlab代码实现与仿真分析流程。该方法通过核函数映射将原始非线性过程数据转换至高维特征空间,进行主成分提取与降维处理,进而构建T²和Q两种统计量用于监控系统运行状态,有效识别工业过程中的早期故障与异常行为。文中详细阐述了KPCA的数学原理、故障检测机制、控制限计算方法,并结合实际案例展示其在复杂非线性系统中的应用效果与优越性,具有较强的工程实用性。; 适合人群:具备一定信号处理、机器学习理论基础及Matlab编程能力的研究生、科研人员和工程技术人员,特别适用于从事工业过程监控、故障诊断、智能制造等相关领域的研究人员。; 使用场景及目标:①应用于化工、电力、制造等行业中关键设备的在线故障监测与早期预警;②作为学术研究中非线性降维与异常检测算法的对比基准;③帮助开发者掌握KPCA模型构建、参数调优及T²-Q统计图可视化等核心技术环节。; 阅读建议:建议读者结合所提供的Matlab代码进行动手实践,深入理解KPCA算法的核心步骤,重点关注核函数选择、主成分数确定及统计量阈值设定等关键参数的影响,以提升故障检测的灵敏度与准确性。

21,500

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧