WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
 
Forum
 

.while loop doesn't stop, .while esi >= 0 dec esi does never stop

Junihausen
Quote Post


New Member
*

Group: Members
Posts: 5
Member No.: 778
Joined: 11-November 04


Sponsored Links
Hi,

I'm using WinAsm with masm32 and wonder why the following code doesn't stop:

mov esi, 2
.while esi >= 0
dec esi
.endw

Does anybody has a clue, why?
PMEmail Poster
Top
Gunner
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 213
Member No.: 27608
Joined: 11-October 09


Don't know how to do it with a .while loop, but this is how I would do it:

CODE

  mov     esi, 2
   Next:
     ; do something here
       dec     esi
       test    esi, esi; is sign bit set?
       jns     Next; sign bit is not set jump to begin of loop
      ; we made it here cause esi is less than 0
PMEmail PosterUsers Website
Top
low_coder
Quote Post


New Member
*

Group: Members
Posts: 15
Member No.: 15247
Joined: 18-November 08


you are doing signed comparison... you should add sdword ptr before esi in the .while loop:

CODE

mov esi, 2
.while sdword ptr esi >= 0
     dec esi
.endw
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian