gladiusmaximus

Find max psuedo-code

Apr 12th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // A = ld(i) means load the ith address into A
  2. // st(i) = A means write A to the ith address
  3.  
  4. // ld(2) is the place where the current index is
  5. // It must start at 8
  6. // ld(3) is the place where the current maximum is
  7. // It must start at 0
  8. @loop
  9. A = ld(2) // what address to go to next?
  10. A = A + 1
  11. ld(2) = A
  12. B = ld(3)
  13. if (A < B) goto @loop
  14. // if you haven't jumped by now, then A >= B
  15. // this means we have a new max
  16. A = ld(2) // what was the index of the new max again?
  17. A = ld(A) // what was the new max again?
  18. // the above uses the loada command
  19. st(3) = A
  20. goto @loop
Advertisement
Add Comment
Please, Sign In to add comment