| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 619 人关注过本帖
标题:关于跳跃地址表的实现
只看楼主 加入收藏
xiaoxun_1122
Rank: 1
来 自:地球
等 级:新手上路
帖 子:14
专家分:0
注 册:2010-10-18
结帖率:50%
收藏
 问题点数:0 回复次数:1 
关于跳跃地址表的实现
程序代码:
DATAS SEGMENT
table  dw prog4,prog1,prog2,prog3,prog4
lat1   db 0ah,0dh,'(1)    GUESS NUMBER GAME       $'
lat2   db 0ah,0dh,'(2)    CHAR SELECTION PROGRAM  $'
lat3   db 0ah,0dh,'(3)    PASSWORD PROGRAM        $'
lat4   db 0ah,0dh,'(4)    PRESS  "ESC" TO  QUIT   $'

mess1 db 0ah,0dh,'input 1-4:$'
mess2 db 0ah,0dh,'Your selection is 1,the program will execute GUESS NUMBER GAME!$'
mess3 db 0ah,0dh,'Your selection is 2,the program will execute CHAR SELECTION PROGRAM!$'
mess4 db 0ah,0dh,'Your selection is 3,the program will execute PASSWORD PROGRAM!$'
mess5 db 0ah,0dh,'Your selection is 4,the program will execute PRESS  "ESC"  TO  QUIT!$'
mess6 db 0ah,0dh,'will you continue program really?(Y:N)$'
mess7 db 0ah,0dh,'Please press ESC key to exit!$'

M db '5'
N db ?
str11 db 0ah,0dh,'now please input a number: ','$'
str12 db 'TOO BIG','$'
str13 db 'TOO SMALL','$'
str14 db 'YOUR ARE RIGHT','$'

str21 db 0ah,0dh,'you can input "<CR>" to go out,if you want go on ,please input others besides "<CR>" $'
str22 db 0ah,0dh,'you input:','$'
str23 db 0ah,0dh,'IT IS A DIGITAL','$'
str24 db 0ah,0dh,'IT IS A LOWCASE LETTER','$'

str31 db '123'   
str32 db 0ah,0dh,'please input a string:','$'
len equ str32-str31  
str_d db 50,?,50 dup(?)
mess31 db 0ah,0dh,'MATCH!$'
mess32 db 0ah,0dh,'NOMATCH!,PROGRAM TERMINATED!$'
DATAS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS
START:
    MOV AX,DATAS
    MOV DS,AX
    push ax
mas:
   lea dx,lat1
   mov ah,09h
   int 21h
   lea dx,lat2
   mov ah,09h
   int 21h
   lea dx,lat3
   mov ah,09h
   int 21h
   lea dx,lat4
   mov ah,09h
   int 21h
  
   mov dx,offset mess1
   mov ah,09h
   int 21h
   mov ah,1
   int 21h
   and al,03h
   mov ah,0
   shl ax,1
   mov bx,ax
   push bx
to:  jmp table[bx]
prog1:
    mov dx,offset mess2
    mov ah,09h
    int 21h
    mov bl,M
    mov dx,offset str11
    mov ah,09h
    int 21h
    mov ah,01h
    int 21h
    mov N,al
    cmp bl,al
    jb  a
    cmp bl,al
    ja  b
    mov dl,0ah
    mov ah,02h
    int 21h
    mov dl,0dh
    int 21h
    mov dx,offset str14
    mov ah,09h
    int 21h
    jmp let1
a:  mov dl,0ah
    mov ah,02h
    int 21h
    mov dl,0dh
    int 21h
    mov dx,offset str13
    mov ah,09h
    int 21h
    jmp let1
b:  mov dl,0ah
    mov ah,02h
    int 21h
    mov dl,0dh
    int 21h
    mov dx,offset str12
    mov ah,09h
    int 21h   
    jmp let1

 
prog2:
    lea dx,mess3
    mov ah,09h
    int 21h
    mov dx,offset str21
    mov ah,09h
    int 21h
    mov dx,offset str22
    mov ah,09h
    int 21h
    mov ah,01h
    int 21h
    cmp al,0dh
    jz exit
    cmp al,'1'   
    jb another
    cmp al,'9'
    ja another
    mov dx,offset str23
    mov ah,09h
    int 21h
    jmp let1
another:
      cmp al,'A'
      jb  another2
      cmp al,'Z'
      ja  another2
      mov dx,offset str24
      mov ah,09h
      int 21h
      jmp let1
another2:
      cmp al,'a'
      jb  another3
      cmp al,'z'
      ja  another3
      mov dx,offset str24
      mov ah,09h
      int 21h
      jmp let1
another3:
      jmp let1
     
prog3:
    lea dx,mess4
    mov ah,09h
    int 21h
    mov dx,offset str32
    mov ah,09h
    int 21h
    pop ax
    mov es,ax
    lea dx,str_d
    mov ah,0ah
    int 21h
    xor cx,cx
    mov cl,str_d+1
    cmp cl,len
    jne ms
    lea si,str31
    lea di,str_d+2
mad:mov al,ds:[si]
    mov bl,es:[di]
    cmp al,bl
    jne ms
    inc si
    inc di
    loop mad
    lea dx,mess31
    mov ah,09h
    int 21h
    jmp  let1
ms:
    lea dx,mess32
    mov ah,09h
    int 21h        
let1:
  pop bx
  lea dx,mess6
  mov ah,09h
  int 21h
  mov ah,01h
  int 21h
  cmp al,'Y'
  jz to
  cmp al,'N'
  jz mas
prog4:
   lea dx,mess5
   mov ah,09h
   int 21h
   lea dx,mess7
   mov ah,09h
   int 21h
   mov ah,01h
   int 21h
   cmp al,27
   jZ exit
   jmp mas
exit:    MOV AH,4CH
    INT 21H
CODES ENDS
    END START
在做第三个程序时,假设我输入‘123’,仍然得到的是nomatch
搜索更多相关主题的帖子: 地址 
2010-12-12 19:32
zaixuexi
Rank: 12Rank: 12Rank: 12
来 自:上海
等 级:火箭侠
威 望:8
帖 子:858
专家分:3233
注 册:2010-12-1
收藏
得分:0 
这个是你的开头
START:
    MOV AX,DATAS
    MOV DS,AX
    push ax
mas:
   lea dx,lat1
   mov ah,09h
   int 21h
   lea dx,lat2
   mov ah,09h
   int 21h
   lea dx,lat3
   mov ah,09h
   int 21h
   lea dx,lat4
   mov ah,09h
   int 21h
  
   mov dx,offset mess1
   mov ah,09h
   int 21h
   mov ah,1
   int 21h
   and al,03h
   mov ah,0
   shl ax,1
   mov bx,ax
   push bx
to:  jmp table[bx]
..................................
这个是你的第三个程序...
prog3:
    lea dx,mess4
    mov ah,09h
    int 21h
    mov dx,offset str32
    mov ah,09h
    int 21h
    pop ax
    mov es,ax
    lea dx,str_d
    mov ah,0ah
    int 21h
    xor cx,cx
    mov cl,str_d+1
    cmp cl,len
    jne ms
    lea si,str31
    lea di,str_d+2
mad:mov al,ds:[si]
    mov bl,es:[di]
    cmp al,bl
红色标注的地方你再想想,呵呵,另外DEBUG调试起来挺方便的,很快就能知道哪不对,学一下,不难的.
收到的鲜花

技术问题,请不要以短消息方式提问
2010-12-12 22:13
快速回复:关于跳跃地址表的实现
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032101 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved