Jump to content

Divisão assembly


cenorasped

Recommended Posts

Limpa o registo DX antes de fazer a divisão.

mov ax, 10h
xor dx, dx             ; ou mov dx, 0
mov cx, 2h
div cx

Explicação:

Citação
DIV performs unsigned integer division. The explicit operand provided is the divisor; the dividend and destination operands are implicit, in the following way:

For DIV r/m8, AX is divided by the given operand; the quotient is stored in AL and the remainder in AH.

For DIV r/m16, DX:AX is divided by the given operand; the quotient is stored in AX and the remainder in DX.

For DIV r/m32, EDX:EAX is divided by the given operand; the quotient is stored in EAX and the remainder in EDX.

http://www.posix.nl/linuxassembly/nasmdochtml/nasmdoca.html

Traduzindo: Se estás a utilizar registos de 16 ou 32 bits, o numerador é DX:AX. Ou seja:

(DX:AX)/CX

  • Vote 2

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.