【问题标题】:TASM:How to printout a register pair dx:ax on screen after multiply?TASM:乘法后如何在屏幕上打印出寄存器对 dx:ax?
【发布时间】:2014-03-09 18:02:29
【问题描述】:
include io.h
cr  equ 0dh
lf  equ 0ah
stacksg segment stack
dw  100 dup(?)
stacksg ends
datasg segment
prp1    db  '1st Number:',cr,lf,0
prp2    db  '2nd Number:',cr,lf,0
prp3    db  'The result:',cr,lf,0
numA    dw  ?
numB    dw  ?
sum     dw  20 dup(?),0
entersim    db  cr,lf

datasg ends
codesg segment
start:
assume cs:codesg,ds:datasg
mov ax,datasg
mov ds,ax
output prp1
inputs numA,10
atoi numA
mov numA,ax
output prp2
inputs numB,10
atoi numB
mov bx,ax
mov ax,numA
mul bx
itoa sum,ax
output entersim
output  prp3
output sum
output entersim


mov al,0
    mov ah,4ch
int 21h

codesg ends
end start   

如果乘法的结果大于 16 位并且答案存储在 dx:ax 对寄存器中,我无法显示整个结果,如何在屏幕上显示操作的正确答案? 如果有这种情况的示例代码,请将其写出来...... tnx朋友

【问题讨论】:

    标签: assembly multiplication tasm


    【解决方案1】:

    您将需要不同版本的 itoa 来将寄存器对 DX:AX 中的 32 位数字显示为无符号十进制数。该数字的最大值为 4294967295。 将 DX:AX 中的数字除以 1000000000,得到商 4。这是第一个输出数字。 减去 4*1000000000,所以现在 DX:AX=294967295。除以 100000000,得到 2。 减去 2*100000000,所以现在 DX:AX=94967295。重复直到处理完所有十位数字。

    20 年前,我为此编写了一个名为 StoDD 的宏,它可以在文件 CPU.MAC 中下载,地址为 http://vitsoft.info/vsasmlib.zip 也许它可以帮助你。

    【讨论】:

      猜你喜欢
      • 2018-08-07
      • 1970-01-01
      • 1970-01-01
      • 2011-11-25
      • 2011-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-02
      相关资源
      最近更新 更多