Hi guys!

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

Thanx!!

This article might help you.

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

.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

Awesomely efficient code you got there! Very sleek.

Awesomely efficient code you got there! Very sleek.

and its so well documented too!:eek: assembly code should have comments on nearly every line.

If you're guaranteed an NPX, just FILD the values and divide them ;->

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. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.