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
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!
Posted on 2001-09-02 07:09:52 by -theNOP-
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.
Posted on 2001-09-02 07:14:31 by Eóin
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??
Posted on 2001-09-02 07:17:48 by -theNOP-
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???
Posted on 2001-09-02 07:21:09 by -theNOP-
instead of:

mov dl,n
div dl
mov al,ah


movzx ecx,n
div ecx
mov eax,edx

Posted on 2001-09-02 07:39:40 by japheth