Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- magicQS:
- mov r0, -(sp)
- mov r1, -(sp)
- mov r2, -(sp)
- mov r3, -(sp)
- mov r4, -(sp)
- mov r5, -(sp)
- mov 16(sp), r2 ; put the arr adress in r2.
- mov #diffArr, r0 ; put the difArr adress in r0.
- mov 14(sp), r1 ; put the length of the arrays in r1.
- createDiff:
- cmp r1, #0
- beq magicDiff
- tst -(sp) ; allocate a place for the result magic number in the stack number.
- mov (r2), -(sp) ; puts the value of the first node of arr in the stack.
- jsr pc, getMagic
- tst (sp)+ ; deallocate the place of the first node which we dont need anymore.
- mov (sp)+, (r0) ; puts the magic number we calculated in the diffArr, and deallocate its place from the stack.
- add #2, r2 ; now r2 points to the next node of arr.
- add #2, r0 ; now r0 points to the next node of diffArr.
- sob r1, createDiff
- magicDiff: mov #diffArr, -(sp) ;
- mov 14(sp), -(sp) ; saves the size of the array in the stack.
- jsr pc, Rec
- Rec: Rec cmp 2(sp), #1 ; checks if the size of the array is 1.
- ble RecEnd
- R1 jsr r5, rand ; calls the func which will give me a random number.
- .word 2(sp) ; the inline parameter - the size of the array.
- tst -(sp) ;allocate a place in the stack for the result of magicPartition.
- mov 4(sp), -(sp) ; restore the adress of the array in the stack.
- mov 2(sp), -(sp) ; restore the size of the array.
- mov r0, -(sp) ; r0 contains the random number which was calculated in rand.
- jsr pc, magicPartition
- mov (sp)+, (sp)+
- tst (sp)+
- mov (sp)+, r1 ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement