1、 附:课程设计报告格式 组成原理实践组成原理实践课程设计报告课程设计报告 题目:题目:简单字符串处理系统的实现简单字符串处理系统的实现 完成日期:完成日期: 20132013 年年 1 1 月月 6 日日 一、 课程设计目的 1、掌握并巩固顺序、分支、循环结构以及子程序结构的汇编程 序设计基本技术和基本方法。 2、 理解计算机在指令系统级的运行原理, 熟悉 DOS 功能子程序 的调用。 3、掌握输入输出子程序的编写。 4、掌握从键盘输入字符(串)与在显示屏上显示字符(串)的 基本方法。 二、课程设计内容 输入一个字符串,扫描该字符串,按数字、字母和特殊字符 3 类,把字符分类输出到屏幕,同时输
2、出各类字符的个数。 三、课程设计过程 1、算法设计(画出算法流程图) 2、程序代码 ; multi-segment executable file template. data segment ; add your data here! string1 db “please input a string:$“ string2 db “sum of chars:$“ string3 db “sum of digits:$“ string4 db “sum of others:$“ chars db 0;字母 digit db 0;数字 others db 0;其他 ends stack segm
3、ent dw 128 dup(0) ends code segment start: ; set segment registers: mov ax, data mov ds, ax mov es, ax ; add your code here lea dx, string1 ;显示输入提示信息 mov ah, 09H ;ah 累加器 09H 屏幕显示功能 int 21h ; output string at ds:dx mov cx,100 ;设置循环次数足够大 L1:mov AH,01H ; 中断调用,单字符输入 int 21h ;输入符号的 ASCII 代码在 AL 寄存器中 cmp
4、AL,0DH ;若输入回车符则结束 jz over2 cmp AL,30H ;若39H,跳转进一步比较 ja higher1 jmp digital ;digit+ higher1:cmp al,41H ;若 if5AH(Z),跳转继续比较 ja higher2 jmp char ;alphau+ higher2:cmp AL,61H ;若 if7AH(z),others+ ja other jmp char ;alphau+ jmp over ;比较结束 other:inc others ;others+ jmp over ;比较结束 char:inc chars ;alphal+ jmp
5、over ;比较结束 digital:inc digit ;digit+ jmp over ;比较结束 over:nop loop L1 ;循环,输入下一字符 over2:call endline ;回车换行 lea dx,string2 ;字符串的输入 char mov ah,09h int 21h xor ax,ax mov al,chars ;将统计的字符送 ax call display ;调用输出两位字符的子程序 call endline lea dx,string3 ;字符串的输出 digits mov ah,09h int 21h xor ax,ax mov al,digit ;
6、将统计的数字送 ax call display ;调用输出两位数字的子程序 call endline lea dx,string4 ;字符串的输入 others mov ah,09h int 21h xor ax,ax mov al,others ; 将统计的数字送 ax call display ;调用输出两位数字的子程序 mov ah,4ch int 21h endline proc near;控制输出格式,输出回车换行子程序 mov ah,02h mov dl,0ah int 21h ;输出换行符 mov ah,02h mov dl,0dh int 21h ;输出回车符 ret endline endp display proc near;输出两位数字的子程序(十进制) mov bl,10 div bl ;ax/bl,al=商,ah=余数 push ax ;保存 ax 中的信息 mov dl,al add dl,30h mov ah,0