can somebody help me to know a vert efficient algorithm in dividing more than 32 bytes of number?

e.g.
65534.99/2326.84=28.1648029
=>6553499/232684 =281648029
=>63 FF 9B/03 8C EC=10 C9 9B 9D
how could that be?

my algo is that use shifts and subs but in a bitwise manner
i want to divide byte by byte and not bit by bit

## All 2 Replies

32 byte dividend is enormous.. out of curiousity why do you have to divide such a precised or huge number? Secondly, what is exactly efficent, the code algorithm in size or how fast can you produce the results? Also, how big should we expect the divisor to be? And lastly which architecture are we looking at here, there would be limitations depending on the what processor we are dealing with.

From your examples, I don't quite understand, really I see a floating point translated to fixed point then to heximals, nothing out of the ordinary if you only require 2 decimal places.

hi try this one..

.model SMALL
.386
.DATA
a1 dB 'Enter the first number\$'
a2 dB 'Enter the second number\$'
A3 DD ?
A4 DD ?
.code
.STARTUP
mov ebx,00000000H
mov edx,00000000H
mov eax,00000000H
mov cl,4

mov dx,offset a1
mov ah,09h
int 21h
MOV EDX,00000000H
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar1
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar2
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar3
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar4
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar5
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar6
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar7
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar8
sub al,07
mov a3,ebx
mov ebx,00000000H
mov dx,offset a2
mov ah,09h
int 21h
MOV EDX,00000000H
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at1
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at2
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at3
sub al,07
shl ebx,cl

mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at4
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at5
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at6
sub al,07
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at7
sub al,07
shl ebx,cl

mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at8
sub al,07

mov edx,00000000H
mov eax,a3
div ebx
mov a4,eax
mov edx,00000000h
mov edx,A4
and edx,0f0000000h
mov cl,28
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,0f000000h
mov cl,24
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,00f00000h
mov cl,20
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,000f0000h
mov cl,16
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,0000f000h
mov cl,12
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,00000f00h
mov cl,08
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,000000f0h
mov cl,04
shr edx,cl
cmp edx,39h
int 21h

mov edx,A4
and edx,0000000fh
mov cl,00
shr edx,cl