标题:请问这个程序错在哪了?为什么输入2位时会不对
只看楼主
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
结帖率:85.71%
已结贴  问题点数:20 回复次数:8 
请问这个程序错在哪了?为什么输入2位时会不对
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
       LEA DX,STR1
       MOV AH,9
       INT 21H
       LEA DX,X
       MOV AH,0AH
       INT 21H
       MOV BX,DX

       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV SI,DX
       MOV DX,0
  CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
     
K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       MOV AH,2
MOV DL,'1'
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
  
       MOV AH,2
       MOV DL,'2'
       JMP EXIT

K0:   
       MOV AH,2
       MOV DL,'0'
       INT 21H
       JMP EXIT

K3:   
       MOV AH,2
       MOV DL,'3'
       INT 21H
       JMP EXIT

K4:   
       MOV AH,2
       MOV DL,'4'
       INT 21H
   
EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START
搜索更多相关主题的帖子: 时会 输入 
2010-12-13 23:24
zaixuexi
Rank: 12Rank: 12Rank: 12
来 自:上海
等 级:火箭侠
威 望:8
帖 子:858
专家分:3233
注 册:2010-12-1
得分:10 
你能把你的代码先贴全么,呵呵

技术问题,请不要以短消息方式提问
2010-12-13 23:56
xiaomarn
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:5
帖 子:348
专家分:2026
注 册:2009-3-18
得分:10 
程序代码:
data segment
    str1 db 'input a number: ',0dh,0ah,'$'
    str2 db 0dh,0ah,'input another number: ',0dh,0ah,'$'
    str3 db 'area','$'
    crlf db 0dh,0ah,'$'
    x db 20
        db ?
        DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS

CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
      

       LEA DX,STR1
       MOV AH,9
       INT 21H
      

       LEA DX,X
       MOV AH,0AH
       INT 21H
      


       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
      

       mov dx,offset crlf
       mov ah,9
       int 21h
       MOV BX,offset x
       MOV SI,offset y
       ;MOV DX,0
        CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
    

K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       MOV AH,2
        MOV DL,'1'
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0

 

       MOV AH,2
       MOV DL,'2'
       int 21h
       JMP EXIT

K0:  

       MOV AH,2
       MOV DL,'0'
       INT 21H
       JMP EXIT

K3:  

       MOV AH,2
       MOV DL,'3'
       INT 21H
       JMP EXIT

K4:  

       MOV AH,2
       MOV DL,'4'
       INT 21H
  

EXIT:

        mov dx,offset str3
        mov ah,9
        int 21h
        MOV AH,4CH
       INT 21H
CODE ENDS
     END START 
这个问题好熟悉,在哪见过?
2010-12-14 15:27
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
得分:0 
回复 3楼 xiaomarn
DATA SEGMENT
STR1 DB 'Please input X',0DH,0AH,'$'
STR2 DB 'Please input Y',0DH,0AH,'$'
F0   DB 'K is 0',0DH,0AH,'$'
F1   DB 'K is 1',0DH,0AH,'$'
F2   DB 'K is 2',0DH,0AH,'$'
F3   DB 'K is 3',0DH,0AH,'$'
F4   DB 'K is 4',0DH,0AH,'$'
   X DB 20
     DB ?
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
       LEA DX,STR1
       MOV AH,9
       INT 21H
       LEA DX,X
       MOV AH,0AH
       INT 21H
       MOV BX,DX

       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV SI,DX

  CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
     
K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       LEA DX,F1
       MOV AH,9
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       LEA DX,F2
       MOV AH,9
       INT 21H
       JMP EXIT

K0:    LEA DX,F0
       MOV AH,9
       INT 21H
       JMP EXIT

K3:    LEA DX,F3
       MOV AH,9
       INT 21H
       JMP EXIT

K4:    LEA DX,F4
       MOV AH,9
       INT 21H
   
EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START
2010-12-14 16:53
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
得分:0 
回复 3楼 xiaomarn
我把程序贴全了,就是检测XY判断在地基象限的,可是为什么么输入两位后输出值总是带了Y的值呢
2010-12-14 16:54
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
得分:0 
回复 3楼 xiaomarn
DATA SEGMENT
STR1 DB 'Please input X',0DH,0AH,'$'
STR2 DB 'Please input Y',0DH,0AH,'$'
   X DB 20
     DB ?
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
       LEA DX,STR1
       MOV AH,9
       INT 21H
       LEA DX,X
       MOV AH,0AH
       INT 21H
       MOV BX,DX

       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV SI,DX
       MOV DX,0
  CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
     
K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       MOV AH,2
MOV DL,'1'
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
  
       MOV AH,2
       MOV DL,'2'
       JMP EXIT

K0:   
       MOV AH,2
       MOV DL,'0'
       INT 21H
       JMP EXIT

K3:   
       MOV AH,2
       MOV DL,'3'
       INT 21H
       JMP EXIT

K4:   
       MOV AH,2
       MOV DL,'4'
       INT 21H
   
EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START
2010-12-14 16:55
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
得分:0 
回复 4楼 flyfx1989
不好意思,第一个输出字符串没问题,第二个程序让直接输出字符就不对了,要怎么改呢
2010-12-14 16:57
xiaomarn
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:5
帖 子:348
专家分:2026
注 册:2009-3-18
得分:0 
程序代码:
DATA SEGMENT
STR1 DB 'Please input X',0DH,0AH,'$'
STR2 DB 0DH,0AH,'Please input Y',0DH,0AH,'$'
F0   DB 0dh,0ah,'K is 0',0DH,0AH,'$'
F1   DB 0DH,0AH,'K is 1',0DH,0AH,'$'
F2   DB 0DH,0AH,'K is 2',0DH,0AH,'$'
F3   DB 0DH,0AH,'K is 3',0DH,0AH,'$'
F4   DB 0DH,0AH,'K is 4',0DH,0AH,'$'
   X DB 20
     DB ?
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS

CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
      

       LEA DX,STR1
       MOV AH,9
       INT 21H
      

       LEA DX,X
       MOV AH,0AH
       INT 21H
      


       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV BX,offset x
       MOV SI,offset y

        CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
    

K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
      

       LEA DX,F1
       MOV AH,9
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
      

       LEA DX,F2
       MOV AH,9
       INT 21H
       JMP EXIT

K0:    LEA DX,F0
       MOV AH,9
       INT 21H
       JMP EXIT

K3:    LEA DX,F3
       MOV AH,9
       INT 21H
       JMP EXIT

K4:    LEA DX,F4
       MOV AH,9
       INT 21H
  

EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START


DATA SEGMENT
STR1 DB 0DH,0AH,'Please input X',0DH,0AH,'$'
STR2 DB 0DH,0AH,'Please input Y',0DH,0AH,'$'
str3 db 0DH,0AH,'$'
   X DB 20
     DB ?
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
       LEA DX,STR1
       MOV AH,9
       INT 21H
       LEA DX,X
       MOV AH,0AH
       INT 21H
       MOV BX,DX

       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV SI,DX
       mov dx,offset str3
       mov ah,9
       int 21h
       MOV DX,0
        CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
     
K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
      
       MOV AH,2
        MOV DL,'1'
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
 
       MOV AH,2
       MOV DL,'2'
       int 21h
       JMP EXIT

K0:   
       MOV AH,2
       MOV DL,'0'
       INT 21H
       JMP EXIT

K3:   
       MOV AH,2
       MOV DL,'3'
       INT 21H
       JMP EXIT

K4:   
       MOV AH,2
       MOV DL,'4'
       INT 21H
   
EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START


[ 本帖最后由 xiaomarn 于 2010-12-14 17:28 编辑 ]
2010-12-14 17:22
flyfx1989
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2010-12-1
得分:0 
回复 2楼 zaixuexi
DATA SEGMENT
STR1 DB 'Please input X',0DH,0AH,'$'
STR2 DB 'Please input Y',0DH,0AH,'$'
   X DB 20
     DB ?
  DB 20 DUP(?)
   Y DB 20
     DB ?
  DB 20 DUP(?)
DATA ENDS
CODE SEGMENT
     ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV ES,AX
       LEA DX,STR1
       MOV AH,9
       INT 21H
       LEA DX,X
       MOV AH,0AH
       INT 21H
       MOV BX,DX

       LEA DX,STR2
       MOV AH,9
       INT 21H
       LEA DX,Y
       MOV AH,0AH
       INT 21H
       MOV SI,DX
       MOV DX,0
  CMP BYTE PTR [BX+2],'-'
       JZ K23
       CMP BYTE PTR [BX+2],'0'
       JZ K0
     
K14:   CMP BYTE PTR [SI+2],'-'
       JZ K4
       CMP BYTE PTR [SI+2],'0'
       JZ K0
       MOV AH,2
MOV DL,'1'
       INT 21H
       JMP EXIT

K23:   CMP BYTE PTR [SI+2],'-'
       JZ K3
       CMP BYTE PTR [SI+2],'0'
       JZ K0
  
       MOV AH,2
       MOV DL,'2'
       JMP EXIT

K0:   
       MOV AH,2
       MOV DL,'0'
       INT 21H
       JMP EXIT

K3:   
       MOV AH,2
       MOV DL,'3'
       INT 21H
       JMP EXIT

K4:   
       MOV AH,2
       MOV DL,'4'
       INT 21H
   
EXIT:  MOV AH,4CH
       INT 21H
CODE ENDS
     END START
2010-12-14 21:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-328908-1-1.html




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

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