user2620534
user2620534

Reputation: 3

Biconditional While Loop in x86 Assembly

Suppose I have a while loop in High Level Language that looks something like:

While i >= 0 and x < 5,

how would the assembly code in x86 look? I've tried thinking of using cmp for the conditional parts of the while statement, but I'm not sure how the AND would be implemented.

Thanks

Upvotes: 0

Views: 816

Answers (1)

jlahd
jlahd

Reputation: 6293

    ;; assuming eax contains i, ecx contains x
myloop:
    test eax, eax
    jl   exitloop  ; i < 0
    cmp  ecx, 5
    jge  exitloop  ; x >= 5
    ;; loop content goes here
    jmp myloop
exitloop:
    ;; life continues after the loop

Upvotes: 1

Related Questions