rand proc n:byte

mov eax, seed

add eax, 1234

mov cx,ax

shr eax,16

xor ax,cx

shl eax,16

mov ax,cx

rol eax,5

add eax, 4321

ror ah, 1

mov cx,ax

shr eax,16

xor ax,cx

shl eax,16

mov ax,cx

mov seed, eax

xor edx, edx

mov dl,n

div dl <--------------

mov al, ah

xor ah, ah

ret

rand endp

this is a excample on randim number genearion i converted to 32, but at the marked line it raises an exception (n is 0f) and seed is 0, because its the first call of the function!

mov eax, seed

add eax, 1234

mov cx,ax

shr eax,16

xor ax,cx

shl eax,16

mov ax,cx

rol eax,5

add eax, 4321

ror ah, 1

mov cx,ax

shr eax,16

xor ax,cx

shl eax,16

mov ax,cx

mov seed, eax

xor edx, edx

mov dl,n

div dl <--------------

mov al, ah

xor ah, ah

ret

rand endp

this is a excample on randim number genearion i converted to 32, but at the marked line it raises an exception (n is 0f) and seed is 0, because its the first call of the function!

Since dl is a byte value the div instruction divides ax by dl. The quotient is place in al. I believe that if its larger than a byte it will raise that exception.

Also you may be dividing by zero.

Also you may be dividing by zero.

i'm pretty sure that i Don't devide by zero, because n is 0f and so is dl...

the other thing sunds like the problem..

but how do i fix it then??

the other thing sunds like the problem..

but how do i fix it then??

hum you ar right..

ax is d521

and d521/0f is e35

so it is too big for al

but how do i do this dividion anyway???

ax is d521

and d521/0f is e35

so it is too big for al

but how do i do this dividion anyway???

instead of:

mov dl,n

div dl

mov al,ah

code:

movzx ecx,n

div ecx

mov eax,edx

japheth

mov dl,n

div dl

mov al,ah

code:

movzx ecx,n

div ecx

mov eax,edx

japheth