编写指令将 26(十进制)加载到寄存器 cx

Write instructions to load 26 (decimal) into register cx

我在将 26 位和其他 2 位十进制数加载到寄存器时遇到问题。

我知道“0”的 ASCII 值为 48,我需要将 48 添加到 0 到 9 之间的任何数字以获得 ASCII 值,但我不知道如何加载 2 位数字。

.model small
.data
.code
main proc


    mov dl, 2



    add dl, 48 ; this makes the character ascii

    ;code for printing a character
    mov ah, 2h
    int 21h ; prints value of dl
endp
end main

...

loading 26 and other 2-digits decimal numbers into registers

这是简单的部分。所有的2位小数都在[10,99].
范围内 要将 加载 到像 CX 这样的寄存器中,您只需编写

mov cx, 10
mov cx, 11
...

你的程序正在做的是完全不同的事情。您正试图显示 这样一个 2 位十进制数。这需要将数字分解为 2 个字符。您可以将数字除以 10。商是要打印的第一个数字,余数是要打印的第二个数字。

mov     ax, cx     ; Division exclusively works with AX
mov     dl, 10     ; Divisor
div     dl         ; AX / DL -> Quotient in AL, Remainder in AH
add     ax, 3030h  ; Make both ASCII at the same time
mov     dx, ax     ; DL holds "quotient"-character, DH holds "remainder"-character
mov     ah, 02h    ; DOS.DisplayCharacter
int     21h
mov     dl, dh     ; Bring "remainder"-character in DL
mov     ah, 02h    ; DOS.DisplayCharacter
int     21h