x86 - Wrong answer from DIV assembly -


i have part of code

mov di,3                                                            mov cx,16   looop:   xor dx,dx   shl bx,1   adc dx,dx   cmp cx,16   je cx16 (it's dec cx , jump loop)    push dx   dec cx   cmp cx,0   je  cx0   mov ax,cx   div di  cmp dx,0 jne looop 

when cx = 3
ax =3
div di
ax become h=55 l= 56
, dx = 1
please tell me did wrong here?

div di divides 32 bit quantity dx:ax di. don't know value bx has, presumably produces dx=1 (due adc dx, dx). division going 0x10003 / 3 = 0x5556 remainder 1, , that's see.

ps: learn use debugger, , read instruction set reference appropriate.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -