The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: remus2k on May 15, 2010, 08:01:41 AM

Title: Test al,al
Post by: remus2k on May 15, 2010, 08:01:41 AM
Hello

I was a very long time not here and coing in the last time again with assembly.

Can any tell me how i can change this in If else statement


      mov esi,[String]
@@:
      mov al,[esi]
       inc esi
     test al,al
        jz  @F
       jnz @B
@@:

I know it a little code, myquestion is only how it in if else statment
I have a long time not coding in asm asm ::)

Thanks

Title: Re: Test al,al
Post by: jj2007 on May 15, 2010, 08:11:28 AM
Quote from: remus2k on May 15, 2010, 08:01:41 AM
Hello

I was a very long time not here and coing in the last time again with assembly.

Can any tell me how i can change this in If else statement


      mov esi,[String]
@@:
      mov al,[esi]
       inc esi
     test al,al
        jz  @F
       jnz @B
@@:

I know it a little code, myquestion is only how it in if else statment
I have a long time not coding in asm asm ::)

Thanks


You can use the Zero? operator:


      mov esi,[String]
      .Repeat
          mov al, [esi]
          inc esi
          test al, al
      .Until Zero?

Title: Re: Test al,al
Post by: remus2k on May 15, 2010, 08:18:18 AM
Thanks for your fast reply

And by "test al,al" If this "if al != 0 goto @Out" ?

Then can could write so?


      mov esi,[String]

          mov al, [esi]
          inc esi
          ;test al, al
         .if al != 0
           jmp @Out
         .endif



Or is this not correct?

Title: Re: Test al,al
Post by: jj2007 on May 15, 2010, 08:40:06 AM
You could integrate the test al, al like this:
      mov esi,[String]
      .Repeat
          mov al, [esi]
          inc esi
      .Until !al
Title: Re: Test al,al
Post by: hutch-- on May 15, 2010, 09:12:58 AM
remus2k,

If you want to keep the code simple you can use the .IF form,


  .if al == 0
    jmp outlabel
  .endif


You can do it better though.


    test al, al
    jnz earlier_label


To do it better again, try this.


    movzx eax, BYTE PTR [esi]  ; zero extend byte in ESI into EAX
    test eax, eax
    jnz earlier_label
Title: Re: Test al,al
Post by: remus2k on May 15, 2010, 09:21:01 AM
Ok now have i this understand
Thanks :U