汇编程序:统计一个字符串里数字的个数(初级版)
sum db 2 dup(?);此处输入数据段代码
string db 25 dup(?);存放字符
tital db Thisprogramis made by wq. ,0dh,0ah
db PLease input the string: ,$
overs db Amout of the nember is : ,$
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
mov ax,offset tital
mov dx,ax
mov ah,09h
int 21h
mov cl,25
mov si,0
mov ax,offset string
mov dx,ax
again: ;输入字符
mov ah,01h
int 21h
cmp al,0dh
jz then
mov string[si],al
inc si
dec cl
jnz again
then:
mov ax,offset string
mov dx,ax
mov si,0
mov bl,0
mov cx,6
exchang:
cmp cx,0
jz over
cmp string[si],30h
jnb next
inc si
dec cx
jmp exchang
next:
cmp string[si],39h
jle calculator
inc si
dec cx
jmp exchang
calculator:
inc si
incbl
dec cx
jmp exchang
over:
lea ax,overs
mov dx,ax
mov ah,09h
int 21h
mov ax,offset sum
mov dx,ax
mov sum[0],bl
add sum[0],30h
mov sum[1],$
mov ax,offset sum
mov dx,ax
mov ah,09h
int 21h
MOV AH,4CH
INT 21H
CODES ENDS
END START
这里是本程序的完善版:http://www.51hei.com/mcu/2466.html
汇编程序字符串初级 相关文章:
- 汇编程序:比较2个字符串是否相同(初级版)(12-01)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)