题目:设有一段英文,其字符变量名为ENG,并以$字符结束。试编写一程序,查对单词SUN在该文中的出现次数,并以格式“SUNXXXX”显示出次数。
1 sta segment stack
2 dw 40h dup(?)
3 top label word
4 sta ends
5
6 datarea segment
7 ENG db 'I AM A SUnY BOY, WHO ALWAYS WATCH THE NBA GAMES .ESPECIALLY I SUPPORT FOR THE SUN TEAM$'
8 total dw ?
9 num db 'SUN$'
10 datarea ends
11
12 code segment
13 assume ds:datarea,ss:sta,cs:code
14 main proc far
15 mov ax,sta
16 mov ss,ax
17 lea sp,top
18 mov ax,datarea
19 mov ds,ax
20
21 ;*************************************************************************************************
22 xor bx,bx
23 xor ax,ax
24 mov si,0
25 l0: mov al,ENG[si]
26 cmp al,'$'
27 je exit
28 ;***********************************************************************************************
29 cmp al,'S'
30 jne goback
31
32 inc si
33 mov al,ENG[si]
34 cmp al,'U'
35 jne goback
36
37 inc si
38 mov al,ENG[si]
39 cmp al,'N'
40 jne goback
41
42 inc bx
43 inc si
44 jmp l0
45 ;*************************************************************************************************
46
47 goback:
48 inc si
49 jmp l0
50
51 ;*************************************************************************************************
52
53 exit:
54 mov total,bx
55 mov ah,09h
56 lea cx,num
57 mov dx,cx
58 int 21h
59
60 ;************************************************************************************************
61 mov cx,4
62 mov bx,total
63 l11:push cx
64 mov cl,4
65 rol bx,cl
66 push bx
67 mov al,bl
68 and al,0fh
69 cmp al,0
70 jb l10
71
72 cmp al,9
73 jna right
74 add al,7
75
76 right:
77 add al,30h
78 mov dl,al
79 mov ah,2
80 int 21h
81
82 pop bx
83 pop cx
84 loop l11
85
86
87 l10:
88 mov ah,4ch
89 int 21h
90 main endp
91 code ends
92 end main
93
94
95
96
97
98
99
100
101