How to print a multiplication result in EDX:EAX in Assembly

When multiplying 32bit numbers in assembly, the result will be put in EDX:EAX combination. The upper half of the result goes into EDX and the lower half goes into EAX. If both EDX and EAX have two parts of a result, how can I print these values to the screen using the Irvine32 bit library? See the sample code and comments:

.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
include Irvine32.inc

.data
    num1 dword 1000000
    num2 dword 1000000
    temp dword ?
    full_result qword ?
.code
main proc
    mov eax, num1
    mul num2 ;Result will be put in EDX:EAX (Upper half of number and Lower half of number)
    ;EDX has the value 232 in decimal. 000000E8 in hex
    ;EAX has the value 3567587328 in decimal. D4A51000 in hex
    ;When you put these numbers togather, you get 000000E8D4A51000 in hex. 
    ;When you convert these numbers back to its decimal representation, we get the correct value of 1000000000000

    ;How to display the result into the screen using Irvine32 library (not 64)
    mov temp, eax
    mov eax, edx ;Put the upper half of result in eax
    call WriteDec ;Write the value in eax
    mov eax, temp ;Put the lower half of result in eax
    call WriteDec

    ;This will prints out 2323567587328 instead of 1000000000000

invoke ExitProcess, 0
main endp
end main

enter image description here

Is there a way to convert this number 2323567587328 in a different form so that I can display the upper half and lower half correctly? (packed BCD, etc.. )

If it is not possible to format this number in a way so that I can have 1000000000000 in two different registers, please let me know how can I assign this value to the full_result qword type variable.



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)