比这篇新的文章:
Codee#2423
比这篇旧的文章: Codee#2421
作者: underredflag, 点击192次, 评论(0), 收藏者(0), , 打分:
所有评论,共0条:( 我也来说两句)
比这篇旧的文章: Codee#2421
Codee#2422
语言: NASM, 标签: 无 2009/06/25发布 8个月前更新作者: underredflag, 点击192次, 评论(0), 收藏者(0), , 打分:
NASM语言: Codee#2422
01 ;*******************************************************************
02 ;program name: 信息检索
03 ;author:曹 政
04 ;create date:2009-06-24
05 ;*******************************************************************
06 datasg segment para 'data'
07 note db 'Message number?','$'
08 messtab db '0','. 2009/06/01 It is Monday. ',13,10,'$'
09 db '1','. 2009/06/02 It is Tuesday. ',13,10,'$'
10 db '2','. 2009/06/03 It is Wednesday. ',13,10,'$'
11 db '3','. 2009/06/04 It is Thursday. ',13,10,'$'
12 db '4','. 2009/06/05 It is Friday. ',13,10,'$'
13 db '5','. 2009/06/06 It is Saturday. ',13,10,'$'
14 db '6','. 2009/06/07 It is Sunday. ',13,10,'$'
15 db '7','. 2009/06/08 It is Monday. ',13,10,'$'
16 db '8','. 2009/06/09 It is Tuesday. ',13,10,'$'
17 messerr db 'Not in message table!','$'
18 count dw 0ah
19 datasg ends
20
21 codesg segment para 'code'
22 ;------------------------------------
23 main proc far
24 assume cs:codesg,ds:datasg
25 start:
26 push ds
27 sub ax,ax
28 push ax
29
30 mov ax,datasg
31 mov ds,ax
32
33 lea dx,note ;输入提示
34 mov ah,09
35 int 21h
36 call ctrlf
37
38 mov ah,01h ;输入选项
39 int 21h
40 cmp al,'q' ;若输入的是q,则退出
41 je exit
42
43 call ctrlf ;显示回车换行
44
45 mov cx,count ;共count项
46 lea si,messtab
47 search: ;从table中查找标号
48 cmp al,[si]
49 je display
50 add si,34
51 loop search
52 jmp showerr
53
54 display:
55 mov dx,si
56 mov ah,09h
57 int 21h
58 jmp exit
59
60 showerr:
61 lea dx,messerr
62 mov ah,09h
63 int 21h
64
65 exit:
66 ret
67 main endp
68 ;---------------------------
69 ctrlf proc near
70 push ax
71 push dx
72 mov dl,0dh
73 mov ah,02h
74 int 21h
75 mov dl,0ah
76 mov ah,02h
77 int 21h
78 pop dx
79 pop ax
80 ret
81 ctrlf endp
82 ;---------------------------
83 codesg ends
84 end start
02 ;program name: 信息检索
03 ;author:曹 政
04 ;create date:2009-06-24
05 ;*******************************************************************
06 datasg segment para 'data'
07 note db 'Message number?','$'
08 messtab db '0','. 2009/06/01 It is Monday. ',13,10,'$'
09 db '1','. 2009/06/02 It is Tuesday. ',13,10,'$'
10 db '2','. 2009/06/03 It is Wednesday. ',13,10,'$'
11 db '3','. 2009/06/04 It is Thursday. ',13,10,'$'
12 db '4','. 2009/06/05 It is Friday. ',13,10,'$'
13 db '5','. 2009/06/06 It is Saturday. ',13,10,'$'
14 db '6','. 2009/06/07 It is Sunday. ',13,10,'$'
15 db '7','. 2009/06/08 It is Monday. ',13,10,'$'
16 db '8','. 2009/06/09 It is Tuesday. ',13,10,'$'
17 messerr db 'Not in message table!','$'
18 count dw 0ah
19 datasg ends
20
21 codesg segment para 'code'
22 ;------------------------------------
23 main proc far
24 assume cs:codesg,ds:datasg
25 start:
26 push ds
27 sub ax,ax
28 push ax
29
30 mov ax,datasg
31 mov ds,ax
32
33 lea dx,note ;输入提示
34 mov ah,09
35 int 21h
36 call ctrlf
37
38 mov ah,01h ;输入选项
39 int 21h
40 cmp al,'q' ;若输入的是q,则退出
41 je exit
42
43 call ctrlf ;显示回车换行
44
45 mov cx,count ;共count项
46 lea si,messtab
47 search: ;从table中查找标号
48 cmp al,[si]
49 je display
50 add si,34
51 loop search
52 jmp showerr
53
54 display:
55 mov dx,si
56 mov ah,09h
57 int 21h
58 jmp exit
59
60 showerr:
61 lea dx,messerr
62 mov ah,09h
63 int 21h
64
65 exit:
66 ret
67 main endp
68 ;---------------------------
69 ctrlf proc near
70 push ax
71 push dx
72 mov dl,0dh
73 mov ah,02h
74 int 21h
75 mov dl,0ah
76 mov ah,02h
77 int 21h
78 pop dx
79 pop ax
80 ret
81 ctrlf endp
82 ;---------------------------
83 codesg ends
84 end start
所有评论,共0条:( 我也来说两句)
代码
