现在的位置: 首页 > 综合 > 正文

= 问题 = 请问如何把16进制数转化为10进制数显示输出?谢谢!

2018年02月11日 ⁄ 综合 ⁄ 共 790字 ⁄ 字号 评论关闭

 = 问题 =
  请问如何把16进制数转化为10进制数显示输出?谢谢! 
 

--------------------------------------------------------------------------------
  16进制数在内存INPUT处,使用大写字母,结果在OUTPUT中 
最大为双字 
大致如下: 

input  db  "23AF ",0 
w1     dw 1 
w2     dw 0 
output db 20 dup(0) 

    xor ax,ax 
    mov si,offset input 
    call h_to_b 
    mov di,offset output 
    mov cx,10 
    call b_to_d 
    xor ax,ax 
    stosb 

h_to_b: 
    lodsb 
    push ax 
    or ax,ax 
    jz b03 
    call h_to_b 
    pop cx 
    cmp cl, "9 " 
    ja b01 
    sub cx, "0 " 
    jmp b02 
b01:sub cx, "A " 
b02:mov ax,w2 
    mul cx 
    mov w2,ax 
    mov ax,w1 
    mul cx 
    mov w1,ax 
    add w2,dx 
b03:ret 

b_to_d: 
    mov ax,w2 
    xor dx,dx 
    div cx 
    mov w2,dx 
    mov dx,ax 
    mov ax,w1 
    div cx 
    mov w1,ax 
    or ax,dx 
    jz w11 
    push dx 
    call b_to_d 
    pop ax 
    add ax,030h 
    stosb 
w11: 
    ret
 
 

抱歉!评论已关闭.