?? string1.asm
字號:
;This program is to find the times of "computer" in a string.
;Designer:yankun
stack segment para stack 'stack'
dw 128 dup(?)
stack ends
;**************************************************************
data segment para 'data'
a db 100 dup(?)
array db 40 dup(?)
wd db 'computer'
frame db "***********************************************************$ "
tip db 13d,10d,"Input the string:(enter space to end)$"
tip1 db 13d,10d,"The count of compurter is:$"
tip2 db 13d,10d,"No such word!$"
data ends
;**************************************************************
code segment
assume cs:code,ds:data,ss:stack
main proc far
start:
mov ax,data
mov ds,ax ;let ds register have data segment address
call introduce
call input
call space
call count
mov ah,07
int 21h
ret
main endp
;**************************************************************
;Introduce ;//輸出提示語句以及菜單
introduce proc near
lea dx,frame
mov ah,09
int 21h
call space
lea dx,frame
mov ah,09
int 21h
ret
introduce endp
;***************************************************************
;Input a string ;//輸入一字符串,保存在空間 a 里。
input proc near
lea dx,tip
mov ah,09h
int 21h
mov si,0
next: mov ah,01
int 21h
cmp al,20h
jz end1
mov a[si],al
inc si
jmp next
end1: mov a[si],al
ret
input endp
;****************************************************************
;To present a space ;//輸出一個換行
space proc near
mov dl,0dh
mov ah,02
int 21h
mov dl,0ah
mov ah,02
int 21h
ret
space endp
;***************************************************************
;Count the times of the word "computer" ;//查找計數過程
count proc near
mov bx,0
mov si,0
mov di,0
first:cmp a[si],20h
jz over
mov al,wd[di] ;//將COMPUTER單詞放在wd字符串里
cmp al,a[si] ;//比較
je next1 ;//相等進入內層循環
inc si
jmp first
next1: cmp di,7 ;//內層循環判斷是否完全匹配
jz addno
inc si
inc di
jmp first
addno:inc bx ;//計數加一
inc si
mov di,0
jmp first
over: cmp bx,0 ;//比較完畢
jz nofind
lea dx,tip1
mov ah,09h
int 21h
call output ;//調用輸出函數
jmp exit
nofind: lea dx,tip2
mov ah,09h
int 21h
exit: ret
count endp
;**********************************************************************************
;Output the times ;//將次數轉化為十進制數來輸出
output proc near
mov di,-1
mov ax,bx
thenext:
inc di
mov cl,10d
div cl
mov array[di],ah
xor ah,ah
cmp al,0
jz print
jmp short thenext
print:
cmp di,0
jl wo
add array[di],48
mov dl,array[di]
mov ah,02
int 21h
sub di,1
jmp short print
wo: ret
output endp
;*************************************************************************8
code ends
end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -