flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem in Loop

Author
Thread Post new topic Reply to topic
Ianis



Joined: 06 Jan 2011
Posts: 10
Ianis
Code:
format PE GUI 4.0
entry EntryPoint

EntryPoint:      
    xor eax, eax
        xor ebx, ebx
        mov ecx, 0FFFFh
     bloop:
          mov al, 7Ah
         sub al, 80h
         mov bx, 0FFh
                idiv bx
     loop bloop
  ret    

Hello I would like to know why the code doesn't loop and get stuck on idiv bx.
Thank you.
Post 17 Mar 2012, 19:40
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
The division is applied to dx:ax, so if dx:ax/bx cannot fit inside ax #DE exception will occur; to fix this zero dx before each idiv (after idiv the remainder is put in dx)
Post 17 Mar 2012, 20:48
View user's profile Send private message Reply with quote
Ianis



Joined: 06 Jan 2011
Posts: 10
Ianis
Thank you a lot cod3b453.
I didn't know it works like that.
Post 18 Mar 2012, 15:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.