比如BCD码为0x23,如何得到一个int整数23?
能给出算法吗?谢谢!!!

解决方案 »

  1.   

    同学,BCD码的编码是8421,就是b0为1,b1为2,b3为4,b4为8,b5为10位。
    0x23 = 0010 0011 = 1* 2 + 1 * 4 + 1*4*10
      

  2.   

    char buffer[255], i;
    sprintf(buf, "%x", BCD);  //转化成字符串
    i = atoi(buf);  //再变回数字
      

  3.   

    BCDto10 MACRO ORG
       push ax
       push bx
       push cx
       xor ax,ax
       mov al,org
       mov bl,al
       and al,0f0h
       mov cl,4
       shr al,cl
       mov cl,10
       mul cl
       and bl,0fh
       add al,bl
       mov org,al
       pop cx
       pop bx
       pop ax
      ENDM