News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Test al,al

Started by remus2k, May 15, 2010, 08:01:41 AM

Previous topic - Next topic

remus2k

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


jj2007

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?


remus2k

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?


jj2007

You could integrate the test al, al like this:
      mov esi,[String]
      .Repeat
          mov al, [esi]
          inc esi
      .Until !al

hutch--

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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

remus2k

Ok now have i this understand
Thanks :U