944,148 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 8084
  • Assembly RSS
Nov 15th, 2006
0

URGENT: Code for 32 Bit Division

Expand Post »
Hi guys!

I need the code for 32 bit division in assembly (8086 architecture) ASAP! Kindly reply to this post!

Thanx!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
only_asm is offline Offline
2 posts
since Nov 2006
Nov 15th, 2006
0

Re: URGENT: Code for 32 Bit Division

This article might help you.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Nov 20th, 2006
0

Re: URGENT: Code for 32 Bit Division

mov edx, hiword ;load edx with hi word of dividend
mov eax, loword ;load eax with lo word of dividend
mov ebx, divisor ;load ebx with divisor
div ebx ;quotient goes into eax, remainder into edx
Reputation Points: 14
Solved Threads: 4
Junior Poster
mathematician is offline Offline
149 posts
since Nov 2006
Dec 22nd, 2006
0

Re: URGENT: Code for 32 Bit Division

.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
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
mytime19 is offline Offline
50 posts
since Dec 2006
Dec 22nd, 2006
0

Re: URGENT: Code for 32 Bit Division

Awesomely efficient code you got there! Very sleek.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Dec 22nd, 2006
0

Re: URGENT: Code for 32 Bit Division

Click to Expand / Collapse  Quote originally posted by cscgal ...
Awesomely efficient code you got there! Very sleek.
and its so well documented too!:eek: assembly code should have comments on nearly every line.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Jan 8th, 2007
0

Re: URGENT: Code for 32 Bit Division

If you're guaranteed an NPX, just FILD the values and divide them ;->
Reputation Points: 31
Solved Threads: 0
Light Poster
Purple Avenger is offline Offline
49 posts
since Jan 2007
Jan 11th, 2007
0

Re: URGENT: Code for 32 Bit Division

If you ask me, this isn't so efficent when it comes to instruction prefetch caches. These days its better to loop then unroll them.
Ryu
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ryu is offline Offline
24 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: I neeed help !!!
Next Thread in Assembly Forum Timeline: Proper process termination





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC