Reputation: 3
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
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