flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with inc instruction.

Author
Thread Post new topic Reply to topic
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 13 Apr 2006, 09:07
I have such code:
Code:
 .NotMatch:
    mov ch, [esi]
    xor ch, 0
    inc esi
    jnz .NotMatch    

And it doesn't work (when it's ran Windows returns error). if I replace "inc esi" before "mov ch, [esi]" it works. Does anybody have any idea, why? And how can I repair that without adding dec before loop and replacing "inc esi"?
Post 13 Apr 2006, 09:07
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 13 Apr 2006, 09:21
I think you need to do something like swap the inc esi and xor ch, 0.
Code:
.NotMatch
  mov ch, [esi]
  inc esi
  xor ch, 0
  jnz .NotMatch    
Post 13 Apr 2006, 09:21
View user's profile Send private message Reply with quote
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 13 Apr 2006, 09:53
it still doesn't work...
Post 13 Apr 2006, 09:53
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 13 Apr 2006, 10:15
not clear what are you doing with "xor ch,0"? it will not change ch. ZF will on when ch=0 only, but it is not usual kind of comparing with zero. please, give examples when it should loop, and when it should not.

regards!
Post 13 Apr 2006, 10:15
View user's profile Send private message Visit poster's website Reply with quote
Kermil



Joined: 26 Oct 2005
Posts: 35
Location: Russia
Kermil 13 Apr 2006, 10:34
Incrementation of esi register change ZF flag. In the end of loop try to check up ch register using the "or" command.

Not clear what do you want in this example, but I try to assume, that you want get length of ascii string. Try to use following code:
Code:
.NotMatch:
    mov ch, [esi]
    or   ch, ch
    jz   .Match
    inc esi
    jmp .NotMatch
.Match:
    
Post 13 Apr 2006, 10:34
View user's profile Send private message ICQ Number Reply with quote
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 13 Apr 2006, 11:25
ok thanks.
Post 13 Apr 2006, 11:25
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.