当前位置: 代码迷 >> 汇编语言 >> 小弟我想把输入字符对应的ascii码打出来,结果不对
  详细解决方案

小弟我想把输入字符对应的ascii码打出来,结果不对

热度:1842   发布时间:2013-02-26 00:00:00.0
我想把输入字符对应的ascii码打出来,结果不对啊
Assembly code
start:    mov ax,data    mov ds,ax        ;input code segment code here    mov ah,01h;//input a character    int 21h    ;sub al,'0';//input into al    mov dh,al    mov dl,al    and dh,0f0h    shr dh,1    shr dh,1    shr dh,1    shr dh,1    and dl,0fh    add dh,30    add dl,30        mov ah,02h;//output    int 21h        mov dl,dh    int 21h

程序运行的时候,我输入一个A,希望输出31
我的程序错在哪里呢?


------解决方案--------------------------------------------------------
add dh,30h
add dl,30h
------解决方案--------------------------------------------------------
写个 进制转换的 子程序吧。

当大于9的时候,LZ没考虑。
  相关解决方案