User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 402,701 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,329 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 4082 | Replies: 2
Reply
Join Date: Aug 2006
Posts: 8
Reputation: mymirror is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mymirror mymirror is offline Offline
Newbie Poster

Help DIVISION algorithm

  #1  
Sep 5th, 2006
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Posts: 24
Reputation: Ryu is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Ryu Ryu is offline Offline
Newbie Poster

Re: DIVISION algorithm

  #2  
Sep 8th, 2006
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.
Reply With Quote  
Join Date: Dec 2006
Location: delhi
Posts: 23
Reputation: mytime19 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mytime19 mytime19 is offline Offline
Newbie Poster

Re: DIVISION algorithm

  #3  
Dec 22nd, 2006
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
ar1:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar2
sub al,07
ar2:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar3
sub al,07
ar3:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar4
sub al,07
ar4:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar5
sub al,07
ar5:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar6
sub al,07
ar6:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar7
sub al,07
ar7:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe ar8
sub al,07
ar8:add bl,al
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
at1:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at2
sub al,07
at2:add bl,al
shl ebx,cl
mov ah,01
int 21h
sub al,30h
cmp al,09
jbe at3
sub al,07
at3:add bl,al
shl ebx,cl

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

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

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
add edx,30h
cmp edx,39h
jbe ad1
add edx,07h
ad1:mov ah,02
int 21h

mov edx,A4
and edx,0f000000h
mov cl,24
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad2
add edx,07h
ad2:mov ah,02
int 21h

mov edx,A4
and edx,00f00000h
mov cl,20
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad3
add edx,07h
ad3:mov ah,02
int 21h

mov edx,A4
and edx,000f0000h
mov cl,16
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad4
add edx,07h
ad4:mov ah,02
int 21h

mov edx,A4
and edx,0000f000h
mov cl,12
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad5
add edx,07h
ad5:mov ah,02
int 21h

mov edx,A4
and edx,00000f00h
mov cl,08
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad6
add edx,07h
ad6:mov ah,02
int 21h

mov edx,A4
and edx,000000f0h
mov cl,04
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad7
add edx,07h
ad7:mov ah,02
int 21h

mov edx,A4
and edx,0000000fh
mov cl,00
shr edx,cl
add edx,30h
cmp edx,39h
jbe ad8
add edx,07h
ad8:mov ah,02
int 21h
.exit
end
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 5:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC