+ -
当前位置:首页 → 问答吧 → 关于菜单的

关于菜单的

时间:2010-12-12

来源:互联网

Assembly code
DATAS SEGMENT
table dw prog1,prog2,prog3,prog4
lat1   db '(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!$'

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

str21 db '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 'Assembly'
len_S equ $-str1
str32 db 'please input a string:','$'   
str_d db 50,?,50 dup(?)
mess31 db 0ah,0dh,'MATCH!$'
mess32 db 0ah,0dh,'NOMATCH!,PROGRAM TERMINATED!$'

DATAS ENDS

STACKS SEGMENT
    ;此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
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,04h
   shl ax,1
   mov bx,ax
   push bx
   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
    
    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 cx,len_S
    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        
    jmp let1
    
let1:
  pop bx
  lea dx,mess6
  mov ah,09h
  int 21h
  mov ah,01h
  int 21h
  cmp al,'Y'
  jz table[bx]
  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
   jmp exit
   
   
exit:    MOV AH,4CH
    INT 21H
CODES ENDS
    END START






两处错误170和199行错误。但我不知怎么改

作者: Nicolealan   发布时间: 2010-12-12

1,
len_S equ $-str1
应为
len_S equ $-str11吧
cmp cx,len_S
改为
cmp cl,len_S ;因为len_S是字节型

2,
jcc 要求的操作数必须是地址,楼主程序里的tab[bx]貌似是变量吧。

作者: masmaster   发布时间: 2010-12-12

str1在哪?
 jz 只能跳到标号吧 JZ table[bx]非法貌似

作者: znxllyuan   发布时间: 2010-12-12

引用 1 楼 masmaster 的回复:
1,
len_S equ $-str1
应为
len_S equ $-str11吧
cmp cx,len_S
改为
cmp cl,len_S ;因为len_S是字节型

2,
jcc 要求的操作数必须是地址,楼主程序里的tab[bx]貌似是变量吧。


 圣凡哥 么么

作者: znxllyuan   发布时间: 2010-12-12

引用 1 楼 masmaster 的回复:
1,
len_S equ $-str1
应为
len_S equ $-str11吧
cmp cx,len_S
改为
cmp cl,len_S ;因为len_S是字节型

2,
jcc 要求的操作数必须是地址,楼主程序里的tab[bx]貌似是变量吧。

 圣凡哥咱俩都不严谨哇~ 居然都用了貌似~
 也许大概可能之类的含糊其辞可不是好习惯哦~
 改正中。。。

作者: znxllyuan   发布时间: 2010-12-12

引用 4 楼 znxllyuan 的回复:
引用 1 楼 masmaster 的回复:
1,
len_S equ $-str1
应为
len_S equ $-str11吧
cmp cx,len_S
改为
cmp cl,len_S ;因为len_S是字节型

2,
jcc 要求的操作数必须是地址,楼主程序里的tab[bx]貌似是变量吧。

圣凡哥咱俩都不严谨哇~ 居然都用了貌似~
也许大概可能之类的含糊其辞可不是好习……

嘿嘿~~

作者: masmaster   发布时间: 2010-12-12