Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1.  
  2. magicQS:
  3. mov r0, -(sp)
  4. mov r1, -(sp)
  5. mov r2, -(sp)
  6. mov r3, -(sp)
  7. mov r4, -(sp)
  8. mov r5, -(sp)
  9. mov 16(sp), r2 ; put the arr adress in r2.
  10. mov #diffArr, r0 ; put the difArr adress in r0.
  11. mov 14(sp), r1 ; put the length of the arrays in r1.
  12. createDiff:
  13. cmp r1, #0
  14. beq magicDiff
  15. tst -(sp) ; allocate a place for the result magic number in the stack number.
  16. mov (r2), -(sp) ; puts the value of the first node of arr in the stack.
  17. jsr pc, getMagic
  18. tst (sp)+ ; deallocate the place of the first node which we dont need anymore.
  19. mov (sp)+, (r0) ; puts the magic number we calculated in the diffArr, and deallocate its place from the stack.
  20. add #2, r2 ; now r2 points to the next node of arr.
  21. add #2, r0 ; now r0 points to the next node of diffArr.
  22. sob r1, createDiff
  23.  
  24. magicDiff: mov #diffArr, -(sp) ;
  25. mov 14(sp), -(sp) ; saves the size of the array in the stack.
  26. jsr pc, Rec
  27.  
  28. Rec: Rec cmp 2(sp), #1 ; checks if the size of the array is 1.
  29. ble RecEnd
  30.  
  31. R1 jsr r5, rand ; calls the func which will give me a random number.
  32. .word 2(sp) ; the inline parameter - the size of the array.
  33. tst -(sp) ;allocate a place in the stack for the result of magicPartition.
  34. mov 4(sp), -(sp) ; restore the adress of the array in the stack.
  35. mov 2(sp), -(sp) ; restore the size of the array.
  36. mov r0, -(sp) ; r0 contains the random number which was calculated in rand.
  37. jsr pc, magicPartition
  38. mov (sp)+, (sp)+
  39. tst (sp)+
  40. mov (sp)+, r1 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement