首页 文章

我如何重新编写这个组合lang.program,以便它可以加倍传递给它的任何数字

提问于
浏览
-3
;DOUBLE This program prompt the user to enter 
;a number <5,
;doubles the number, and outputs the result

            name    double
            .model  small
            .stack

            .data
prompt      db 0ah,0dh,"Enter a number <5:$"
msg         db 0ah,0dh,"Double your number is :"
result      db ?,0ah,0dh,"$"

            .code
start:
            mov ax,@data
            move ds,ax
            lea dx,prompt
            mov ah,9           ;dos fn to outputstring up to $
            int 21h
            mov ab,1               ;dos fn to input byte into al
            int 21h
            sub al,30h             ;Convert from ascii to single digit integer
            add al,al
            add al,30h             ;Convert back to ascii
            mov result,al
            lea dx,msg
            mov ah,9
            int 21h
            mov ax,4c00h            ;4c in ah is dos exit
            int 21h
            end start

1 回答

  • 0

    输入多位数字:从0开始,然后将到目前为止的值乘以10,添加新数字,对输入的所有数字重复 .

    输出多位数:以空字符串开头,反复将数字除以10;保持商数 . 除法的其余部分告诉哪个数字PREPEND到输出字符串 . 当值大于0时,对商重复 .

    使用其他基数:将上面的“十”替换为代表基数的数字 .

相关问题