
汇编程序设计 字符数统计
题目:从键盘输入一系列以$结束的字符串,统计其中数字字符的个数,并将结果存于COUNT中.小程序,大家看看啊2另:已知在数据区有一长度为100的字符串.起始地址为STR....
题目:从键盘输入一系列以$结束的字符串,统计 其中数字字符的个数,并将结果存于COUNT中.
小程序,大家看看啊
2另:已知在数据区有一长度为100的字符串.起始地址为STR.统计该字符串只能够带*的符号个数.并存于COUNT单元中,不允许使用串操作指令. 展开
小程序,大家看看啊
2另:已知在数据区有一长度为100的字符串.起始地址为STR.统计该字符串只能够带*的符号个数.并存于COUNT单元中,不允许使用串操作指令. 展开
1个回答
展开全部
; 从键盘输入一系列以$结束的字符串,统计 其中数字字符的个数,并将结果存于COUNT中.
; 本程序通过编译,运行正确。
Code Segment
Assume CS:Code,DS:Code
; ----------------------------------------------------------------------------
; 功能:显示指定地址(Str_Addr)的字符串
; 入口:
; Str_Addr=字符串地址(要求在数据段)
; 用法: Output Str_Addr
; 用法举例:Output PromptStr
Output MACRO Str_Addr
lea dx,Str_Addr
mov ah,9
int 21h
EndM
; ----------------------------------------------------------------------------
Prompt_Str db 'Please input a series charactors:$'
COUNT db ?
Start: push cs
pop ds ;使数据段与代码段在同一个段
Output Prompt_Str ;提示输入数字
lea dx,String
mov ah,0ah
int 21h
lea si,String
lodsw
xchg ah,al
xor ah,ah
push ax
pop cx
mov COUNT,0
cld
Statising: lodsb
cmp al,'$'
je Exit_Proc
cmp al,'0'
jb Next_one
cmp al,'9'
ja Next_one
inc COUNT
Next_one: loop Statising
Exit_Proc: mov ah,4ch ;结束程序
int 21h
String db 255,0
Code ENDS
END Start ;编译到此结束
第二个问题
; 本程序通过编译,运行正确。
; 已知在数据区有一长度为100的字符串.起始地址为STR.统计该字符串只能够带*的符号个数.并存于COUNT单元中,不允许使用串操作指令.
Code Segment
Assume CS:Code,DS:Code
; ----------------------------------------------------------------------------
; 功能:显示指定地址(Str_Addr)的字符串
; 入口:
; Str_Addr=字符串地址(要求在数据段)
; 用法: Output Str_Addr
; 用法举例:Output PromptStr
Output MACRO Str_Addr
lea dx,Str_Addr
mov ah,9
int 21h
EndM
; ----------------------------------------------------------------------------
Buffer db 100 dup(?)
COUNT db 0
Start: push cs
pop ds ;使数据段与代码段在同一个段
lea si,Buffer
mov cx,100
cld
Statising: lodsb
cmp al,'*'
jne Next_one
inc COUNT
Next_one: loop Statising
Exit_Proc: mov ah,4ch ;结束程序
int 21h
Code ENDS
END Start ;编译到此结束
; 本程序通过编译,运行正确。
Code Segment
Assume CS:Code,DS:Code
; ----------------------------------------------------------------------------
; 功能:显示指定地址(Str_Addr)的字符串
; 入口:
; Str_Addr=字符串地址(要求在数据段)
; 用法: Output Str_Addr
; 用法举例:Output PromptStr
Output MACRO Str_Addr
lea dx,Str_Addr
mov ah,9
int 21h
EndM
; ----------------------------------------------------------------------------
Prompt_Str db 'Please input a series charactors:$'
COUNT db ?
Start: push cs
pop ds ;使数据段与代码段在同一个段
Output Prompt_Str ;提示输入数字
lea dx,String
mov ah,0ah
int 21h
lea si,String
lodsw
xchg ah,al
xor ah,ah
push ax
pop cx
mov COUNT,0
cld
Statising: lodsb
cmp al,'$'
je Exit_Proc
cmp al,'0'
jb Next_one
cmp al,'9'
ja Next_one
inc COUNT
Next_one: loop Statising
Exit_Proc: mov ah,4ch ;结束程序
int 21h
String db 255,0
Code ENDS
END Start ;编译到此结束
第二个问题
; 本程序通过编译,运行正确。
; 已知在数据区有一长度为100的字符串.起始地址为STR.统计该字符串只能够带*的符号个数.并存于COUNT单元中,不允许使用串操作指令.
Code Segment
Assume CS:Code,DS:Code
; ----------------------------------------------------------------------------
; 功能:显示指定地址(Str_Addr)的字符串
; 入口:
; Str_Addr=字符串地址(要求在数据段)
; 用法: Output Str_Addr
; 用法举例:Output PromptStr
Output MACRO Str_Addr
lea dx,Str_Addr
mov ah,9
int 21h
EndM
; ----------------------------------------------------------------------------
Buffer db 100 dup(?)
COUNT db 0
Start: push cs
pop ds ;使数据段与代码段在同一个段
lea si,Buffer
mov cx,100
cld
Statising: lodsb
cmp al,'*'
jne Next_one
inc COUNT
Next_one: loop Statising
Exit_Proc: mov ah,4ch ;结束程序
int 21h
Code ENDS
END Start ;编译到此结束

2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询