| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 541 人关注过本帖
标题:任意五个数字相加 要求判断 求助!!!!
只看楼主 加入收藏
陛下
Rank: 2
来 自:南宁
等 级:论坛游民
帖 子:62
专家分:90
注 册:2010-5-15
结帖率:42.86%
收藏
已结贴  问题点数:20 回复次数:1 
任意五个数字相加 要求判断 求助!!!!
程序代码:
这个是我做的 但是我不知道怎么回事输进去的数字相加错误
求解...
DATA SEGMENT
    X      DB 5 DUP(?)
    Y      DB 5 DUP(?)
    Z      DB 5 DUP(?)
    STR    DB "Please input the string numbers$"
   
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
GO:     LEA DX,STR
        MOV AH,09H
        INT 21H
    MOV SI,0
    MOV CX,5
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
BG:
    MOV AH,01H
    INT 21H
    CMP AL,3O  ;判断al减去30h是否大于等于0
    JS GO       ;小于0继续跳到输入BG
    CMP AL,3AH
    JNS GO
    SUB AL,3O
    MOV X[SI],AL
    INC SI
    LOOP BG
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV DL,2BH   ;'+'
    MOV AH,02H
    INT 21H
;++++++++++++++++++++++++++++++++++++++++++++++++++++
BG1:   
    MOV SI,0
    MOV CX,5
;+++++++++++++++++++++++++++++++++++++++++++++++++++
BG2:
    MOV AH,01H
    INT 21H
    CMP AL,30H
    JS BG1
    CMP AL,3AH
    JNS BG1
    SUB AL,30H
    MOV Y[SI],AL
    INC SI
    LOOP BG2
;++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV DL,3DH
    MOV AH,02H
    INT 21H
;++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV SI,4
    MOV CX,5
    MOV AH,0
OPR1:    MOV AL,X[SI]
    MOV BL,Y[SI]
    ADD AL,BL
    AAA
    MOV Z[SI],AL
    DEC SI
    LOOP OPR1
;+++++++++++++++++++++++++++++++++++++++++++++++++++
    SUB AH,0
    JNZ OPR2
    JMP OPR3
OPR2:
    MOV DL,AH   
    ADD DI,30H
    MOV AH,02H
    INT 21H
OPR3:
    MOV SI,0
    MOV CX,5
FINAL:    MOV AL,Z[SI]
    ADD AL,30H
    INC SI
    MOV DL,AL
    MOV AH,02H
    INT 21H
    LOOP FINAL
    JMP   $
CODE ENDS
    END START
   
;+++++++++++++++++++++++++++++++++++++++++++++++++++   
    


2010-12-24 17:26
xiaomarn
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:5
帖 子:348
专家分:2026
注 册:2009-3-18
收藏
得分:20 
程序代码:
DATA SEGMENT
    X      DB 5 DUP(?)
    Y      DB 5 DUP(?)
    Z      DB 5 DUP(?)
    STR    DB "Please input the string numbers",'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
    MOV AX,DATA
    MOV DS,AX
GO:     LEA DX,STR
        MOV AH,09H
        INT 21H
    MOV SI,0
    MOV CX,5
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
BG:
    MOV AH,01H
    INT 21H
    CMP AL,30h  ;判断al减去30h是否大于等于0
    JS GO       ;小于0继续跳到输入BG
    CMP AL,3AH
    JNS GO
    SUB AL,30h
    MOV X[SI],AL
    INC SI
    LOOP BG
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV DL,2BH   ;'+'
    MOV AH,02H
    INT 21H
;++++++++++++++++++++++++++++++++++++++++++++++++++++
BG1:  

    MOV SI,0
    MOV CX,5
;+++++++++++++++++++++++++++++++++++++++++++++++++++
BG2:
    MOV AH,01H
    INT 21H
    CMP AL,30H
    JS BG1
    CMP AL,3AH
    JNS BG1
    SUB AL,30H
    MOV Y[SI],AL
    INC SI
    LOOP BG2
;++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV DL,3DH    ;'='
    MOV AH,02H
    INT 21H
;++++++++++++++++++++++++++++++++++++++++++++++++++
    MOV SI,4
    MOV CX,5
    MOV AH,0
   

OPR1:    MOV AL,X[SI]
    MOV BL,Y[SI]
    add AL,BL
    add al,ah
    cmp al,0ah
    jb oop
    mov ah,1
    sub al,0ah
    jmp oop2
oop:
    xor ah,ah
oop2:
    MOV Z[SI],AL
    DEC SI
    LOOP OPR1
;+++++++++++++++++++++++++++++++++++++++++++++++++++
    SUB AH,0
    JNZ OPR2
    JMP OPR3
OPR2:
    MOV DL,AH  

    ADD DI,30H
    MOV AH,02H
    INT 21H
OPR3:
    MOV SI,0
    MOV CX,5
FINAL:    MOV AL,Z[SI]
    ADD AL,30H
    INC SI
    MOV DL,AL
    MOV AH,02H
    INT 21H
    LOOP FINAL
    mov ah,4ch
    int 21h
CODE ENDS
    END START
ok,输入时不要换行,没加入输入了非数字不显示的功能
2010-12-24 21:23
快速回复:任意五个数字相加 要求判断 求助!!!!
数据加载中...
 
   



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

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