Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tutorial by Bad Luck Brian
- Calling a function
- in C# we call our functions like this: Example(arg1, arg2, arg3);
- example: MessageBox.Show("Bad Luck Brian", "title here");
- in powerpc its a bit more complicated but its still simple ^^
- we will use 'bl'
- bl is like 'b', it jumps to a location but bl will continue to the next line with the returned value
- example of 'b'
- :0 li r3, 0x15
- :1 b 6
- :2 //Not executed
- :3 //Not executed
- :4 //Not executed
- :5 //Not executed
- :6 //stuff goes here, its a function..executed
- :0 li r3, 0x15
- :1 bl :6 //goto :6 and when done with it continue at :2
- :2 // executed
- :3 // executed
- :4 // executed
- :5 // executed
- :6 //executed
- calling functions in powerpc is a must and we will use it really often.
- i will make some examples later on calling functions
- There is another way of calling functions, we will use pointers.
- we use mtctr and bctrl
- we use mtctr like this:
- mtctr REGISTER
- Register = register containing the address to call
- and to call it we just use bctrl
- example:
- Code:
- //0x2100000 contains: 00 12 34 56 (0x123456),
- //0x123456 = function i wanna call
- lis r3, 0x210 //loads the address: 0x2100000 in r3
- lwz r3, r3 //read at: 0x2100000 and store the value in r3 (4 bytes)
- mtctr r3 //store r3 in the count register
- bctrl //call the value in the count register
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement