| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 740 人关注过本帖
标题:求大神帮忙解一个简单汇编程序(数制之间的转换)
只看楼主 加入收藏
商殇
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-6-15
结帖率:100%
  已结贴   问题点数:20  回复次数:5   
求大神帮忙解一个简单汇编程序(数制之间的转换)
键盘输入2位十六进制数,屏幕输出对应的十进制数和二进制数,要求二者在同一行显示,以2个空格作为分隔符,在下一行显示该十六进制数交换后的值,完成程序
(附带解释更好)
QQ:885471768

[此贴子已经被作者于2018-6-16 07:55编辑过]

2018-06-15 17:14
商殇
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-6-15
  得分:0 
求大神回复
2018-06-16 18:20
Valenciax
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:10
帖 子:204
专家分:1362
注 册:2016-5-15
  得分:0 
如果楼主早一年注册,贴子(不是纯灌水)超过30,我会无偿给你解答.
或者
楼主至少有一个思路,写了若干代码却卡在什么地方,我也会无偿给你解答.
2018-06-18 08:07
商殇
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-6-15
  得分:0 
回复 3楼 Valenciax
CODE  SEGMENT
              ASSUME    CS:CODE
 
        BUFF  DB        3,?,3 DUP(?)
        ERRR  DB        13,10,'error $'
        LFCR  DB        13,10,'$'
 
      START:  PUSH      CS
              POP       DS
              PUSH      CS
              POP       ES
         @0:
              MOV       AH,10
              LEA       DX,BUFF
              INT       21H
 
              LEA       SI,BUFF
              MOV       CL,[SI+1]
              MOV       CH,0
              CLD
              ADD       SI,2
              MOV       BL,0
         @1:
              LODSB
              CMP       AL,'0'
              JB        @10
              CMP       AL,'9'
              JBE       @9
              CMP       AL,'A'
              JB        @10
              CMP       AL,'F'
              JBE       @8
              CMP       AL,'a'
              JB        @10
              CMP       AL,'f'
              JBE       @7
              JMP       @10
         @7:
              SUB       AL,'a'
              ADD       AL,10
              JMP       @11
         @8:
              SUB       AL,'A'
              ADD       AL,10
              JMP       @11
         @9:
              SUB       AL,'0'
              JMP       @11
        @10:
              LEA       DX,ERRR
              MOV       AH,9
              INT       21H
              JMP       @0
        @11:
              ROL       BL,1
              ROL       BL,1
              ROL       BL,1
              ROL       BL,1
              ADD       BL,AL
              LOOP      @1
              MOV       AL,BL
              MOV       AH,0
              PUSH      AX
              PUSH      AX
               
              MOV       AH,9
              LEA       DX,LFCR
              INT       21H
 
              POP       AX
              CALL      DSPAX10
              POP       AX
              CALL      DSPAX2
               
              MOV       AH,4CH
              INT       21H
;================================   
      DSPAX2  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSHF
              XOR       CX,CX
              MOV       BX,2
  @DSPAX2_1:
              XOR       DX,DX
              DIV       BX
              INC       CX
              OR        DX,30H
              PUSH      DX
              CMP       AX,0
              JNE       @DSPAX2_1
              MOV       AH,2
 @DISPAX2_2:
              POP       DX
              CMP       DL,3AH
              JB        @DISPAX2_3
              ADD       DL,7
 @DISPAX2_3:
              INT       21H
              LOOP      @DISPAX2_2
              MOV       DL,32
              INT       21H
              POPF
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
      DSPAX2  ENDP
;================================   
     DSPAX10  PROC      NEAR
              PUSH      AX
              PUSH      BX
              PUSH      CX
              PUSH      DX
              PUSHF
              XOR       CX,CX
              MOV       BX,10
 @DSPAX10_1:
              XOR       DX,DX
              DIV       BX
              INC       CX
              OR        DX,30H
              PUSH      DX
              CMP       AX,0
              JNE       @DSPAX10_1
              MOV       AH,2
            @DISPAX10_2:
              POP       DX
              CMP       DL,3AH
              JB        @DISPAX10_3
              ADD       DL,7
            @DISPAX10_3:
              INT       21H
              LOOP      @DISPAX10_2
              MOV       DL,32
              INT       21H
              POPF
              POP       DX
              POP       CX
              POP       BX
              POP       AX
              RET
     DSPAX10  ENDP
;================================              
        CODE  ENDS
              END       START





注释:要求是“以两个空格作为间隔”该程序是一个空格;
最后一句,“在下一行显示该十六进制数交换后的值”,该程序没有编辑。
要求举例:
输入:3A
输出:A3


速回谢谢!!!
2018-06-20 18:11
Valenciax
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:10
帖 子:204
专家分:1362
注 册:2016-5-15
  得分:20 
照看,这不是楼主写的代码,不符我希望提问者自己写的要求.
嗯,好吧,只此一次,下不为例.


删除            

 POP       AX
 CALL      DSPAX2

改为
程序代码:

          MOV       DL,20H  
          MOV     AH,2
              INT    21H
              POP       AX
              CALL      DSPAX2
              MOV       AH,9
              LEA       DX,LFCR
              INT       21H
          LEA       BX,BUFF+2
              MOV    AX,[BX]
              XCHG     AH,AL
          MOV     WORD PTR LFCR,AX
              MOV       AH,9
              LEA       DX,LFCR
              INT       21H
2018-06-20 20:02
商殇
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-6-15
  得分:0 
回复 5楼 Valenciax
感谢大神,我肯定好好努力
2018-06-20 22:22







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

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