code_junkie

Use “greater than or equals” or just “greater than”

Nov 11th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. i > -1
  2.  
  3. i >= 0
  4.  
  5. ;; if (i > -1) {
  6. cmp eax, -1
  7. jle else
  8. then:
  9. ...
  10. else:
  11.  
  12. ;; if (i >= 0) {
  13. cmp eax, 0
  14. jl else
  15. then:
  16. ...
  17. else:
  18.  
  19. // if (i >= 0) { (assuming i is in register %t0)
  20.  
  21. stl $t1, $0, $t0 // in C: t1 = (0 < t0)
  22. beq $t1, $0, else // jump if t1 == 0, that is if t0 >= 0
  23. nop
  24. then:
  25. ...
  26. else:
  27.  
  28. // if (i > -1) { (assuming i is in register %t0)
  29.  
  30. addi $t2, $0, -1 // in C: t2 = -1
  31. stl $t1, $t2, $t0 // in C: t1 = (t2 < t0) = (-1 < t0)
  32. bne $t1, $0, else // jump if t1 != 0, that is if t0 > -1
  33. nop
  34. then:
  35. ...
  36. else:
  37.  
  38. if (length >= str.size())
  39.  
  40. if (length > str.size() - 1)
Add Comment
Please, Sign In to add comment