2016-10-02 32 views
0

我正在爲我的學校及其打印已簽名和未簽名的數字進行組裝實驗。它不斷打印無限量的「 - /」,但它應該打印一個數字。數字到ASCII值的偏移是否爲30h?在程序集中打印單個和未簽名的數字

Display .EQU 04E9h 

    NumAddr .EQU 0050h 

Main: 

    mov BX, NumAddr 
    mov DX, Display 

mainLoop: 


    MOV AH,[BX] 

    cmp AH, 0h  ; is number 0? 
    JE EndPrt  ; if yes we are done 

    CMP AH,0h 
    JG posNum   ; should jump to posNum if AH is positive 

negNum: 

    mov AL, 2Dh  
    out DX,AL   ; print a negative sign 

    NEG AH   ; turn AH into a positive number 

printPos: 

    MOV AL,[BX] 
    ADD AL, 30h  ; should add required offset to convert to ASCII 
    out DX,AL 

    MOV AL, 0Dh 
    out DX,AL 
    MOV AL, 0Ah 
    out DX,AL 

    inc BX 

    jmp mainLoop 

EndPrt: 

    HLT 

.END Main 

回答

0

30h是偏移的單個數字。 IE瀏覽器。 (4 + 30h)爲34h,ASCII編碼爲'4'。但對於(17 + 30h),您將獲得41h,這是字符'A'

如果希望值17的兩個字符,如31H「1」和37H「7」時,必須將數分成單獨的基(十進制)個數字(用其除以10,並收集剩餘部分)。