How can I collect the remainders of a div instruction into a register so that it can be converted into a string and displayed to the console. For example:
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
adrs1 dd 0
adrs2 dd 0
.code
start:
mov eax, 6 ; add 6 to eax
mov ebx, 7 ; add 7 to ebx
imul eax, ebx ; multiply both numbers, result is in eax
mov ecx, 10 ; add 10 to ecx
idiv eax:ecx, edx ; divide eax (result of mul) by 10 so that I can separate the digits into single characters so I can display them.
; Numbers will be 4 and 2. Is the result of the division stored in EDX?
mov adrs1, eax ; mov the '4' from the '42' result of the multiplication into 'adrs'
mov adrs2, edx ; mov the remainder of the division to adrs2
add adrs1, 50 ; make the result the correct ASCII character for the result
add adrs2, 50 ; " "
invoke StdOut, addr adrs1 ; display adrs1
invoke StdOut, addr adrs2 ; display adrs2
invoke ExitProcess, 0 ; exit
end start
I need to display the remainders of the division. Any help would be greatly appreciated.
Thanks in advance,
Progrmr
divinstruction goes intoedx. BTW why don't you use the BCD features of the x86?