将十进制数的ASCII码转换为BCD码(汇编)

STACK1 SEGMENT STACK
      DW 256 DUP(?)
STACK1 ENDS
DATA SEGMENT
      BUF DB 30H,30H,31H,32H
DATA ENDS
CODE SEGMENT
      ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
      MOV DS,AX
      MOV SI,OFFSET BUF
      MOV BX,000AH
      MOV CX,0004H
      MOV AH,00H
      MOV AL,[SI]
      SUB AL,30H
 A1:  IMUL BX
      ADD AL,[SI+01]
      SUB AL,30H
      INC SI
      LOOP A1
      MOV [SI],AX
      CALL SHOW
      MOV AX,4C00H
      INT 21H
SHOW PROC NEAR
      MOV AL,DS,:[SI]
      AND AL,0F0H
      MOV CL,4
      SHR AL,CL
      CMP AL,0AH
      JB C2
      ADD AL,07H
C2:  ADD AL,30H
      MOV DL,AL
      MOV,AH,02H
      INT 21H
      MOV AL,DS:[SI]
      AND AL,0FH
      CMP AL,0AH
      JB C3
      ADD AL,07H
C3:ADD AL,30H
      MOV DL,AL
      MOV AH,02H
      INT 21H
      RET
SHOW ENDP
CODE ENDS
 END START

阅读更多
换一批

没有更多推荐了,返回首页