|
发表于 2012-9-28 00:20:16
|
显示全部楼层
鱼丸醋面 发表于 2012-9-29 22:38
加 油!!!^^
修改了下你自己看下满意不- assume cs:cseg,ds:dseg
- dseg segment
- db 100 dup (0)
- db 100 dup (0)
- szyes db 'Yes',0dh,0ah,'$'
- szno db 'NO',0dh,0ah,'$'
- szText1 db 'Please input first string and press Enter';提示信息
- szText2 db 'Please input Second string and press Enter';提示信息
- dseg ends
- cseg segment
- start:
- call QP
- call XS1
- mov ax,dseg
- mov ds,ax
- mov si,0
- mov di,100
- do:
- mov ah,1
- int 21h
- cmp al,0dh ;判断是否为回车键
- je str_next
- mov [si],al
- inc si
- jmp do
-
- str_next:
- call newline
- call QP
- call XS2
- do2:
- mov ah,1
- int 21h
- cmp al,0dh
- je bijiao
- mov [di],al
- inc di
- jmp do2
-
- bijiao:
- call newline
- mov ch,0
- mov si,0
- mov di,100
- s:
- mov cl,[si]
- cmp cl,[di]
- jne no
- jcxz yes
- inc si
- inc di
- jmp s
-
- no:
- mov dx,offset szno
- mov ah,9h
- int 21h
- jmp over
-
- yes:
- mov dx,offset szyes
- mov ah,9h
- int 21h
-
- over:
- mov ah,1
- int 21h
- mov ax,4c00h
- int 21h
- ;换行子程序
- ;说明:直接引用即可
- newline proc
- push ax
- push dx
- mov dl,0dh
- mov ah,2h
- int 21h
- mov dl,0ah
- mov ah,2h
- int 21h
- pop dx
- pop ax
- ret
- newline endp
- ;清屏子程序
- QP proc
- push cx;虽然这一系列保存没什么用,但是可以增加子程序独立性
- push ax
- push ds
- push si
-
- mov cx,4000;字符串个数
- mov ax,0b800h;显存地址
- mov ds,ax
- mov si,0
- lls:
- mov byte ptr ds:[si],0;放入显存
- add si,2;指向下一个显存
- loop lls
-
- pop si
- pop ds
- pop ax
- pop cx
- ret
- QP endp
- XS1 proc
- push ax
- push ds
- push bx
- push es
- push si
- push cx
- mov ax,0b800h
- mov ds,ax
- mov bx,0
- mov ax,dseg
- mov es,ax
- mov si,offset szText1
- mov cx,41;字符数
- ss1:
- mov al,es:[si]
- mov byte ptr [bx],al;放入显存
- add bx,2;指向下一个显存
- inc si;指向下一个字符串
- loop ss1
-
- pop cx
- pop si
- pop es
- pop bx
- pop ds
- pop ax
- ret
- XS1 endp
- XS2 proc
- push ax
- push ds
- push bx
- push es
- push si
- push cx
- mov ax,0b800h
- mov ds,ax
- mov bx,0
- mov ax,dseg
- mov es,ax
- mov si,offset szText2
- mov cx,42;字符数
- ss2:
- mov al,es:[si]
- mov byte ptr [bx],al;放入显存
- add bx,2;指向下一个显存
- inc si;指向下一个字符串
- loop ss2
-
- pop cx
- pop si
- pop es
- pop bx
- pop ds
- pop ax
- ret
- XS2 endp
- cseg ends
- end start
复制代码
补充内容 (2012-9-29 23:29):
嗯。清屏用INT 10 也可以实现好像,具体你自己改 |
|