Pergunta

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   

i can not show the whole result in cases that the result of multiply is bigger than 16bit and the answer is stored on dx:ax pair register,how can i dispaly the correct answer of the operation in the screen? if have sample code for this situation write it out... tnx friends

Foi útil?

Solução

You will need different version of itoa to display 32bit number from register pair DX:AX as unsigned decadic number. Maximum value of such number is 4294967295. Divide the number in DX:AX by 1000000000, giving the quotient 4. This is the 1st output digit. Subtract 4*1000000000, so now DX:AX=294967295. Divide by 100000000, giving 2. Subtract 2*100000000, so now DX:AX=94967295. Repeat until all ten digits are processed.

Twenty years ago I wrote a macro called StoDD for this, it is available for download in the file CPU.MAC at http://vitsoft.info/vsasmlib.zip Maybe it could help you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top