Fibonacci in PowerPC ASM - Printable Version +- Mario Kart Wii Gecko Codes, Cheats, & Hacks (https://mariokartwii.com) +-- Forum: Hacks/Modding (https://mariokartwii.com/forumdisplay.php?fid=14) +--- Forum: Coding & Hacking General Discussion (https://mariokartwii.com/forumdisplay.php?fid=23) +--- Thread: Fibonacci in PowerPC ASM (/showthread.php?tid=957) |
Fibonacci in PowerPC ASM - Vega - 11-23-2018 I was asked by a random person on Discord if I could make a Fibonacci sequence on PPC ASM. Example: x + y = z 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5 etc etc He wanted the equation to loop and repeat until X equals 255 then the loop will start from the very beginning again. Anyway here's a quick fibonacci ASM sequence if anybody cares... Ofc, modify this according to store/load to/from memory addresses for use in Cheat Codes... first_label: li r16, 0x0 #Set X value li r17, 0x1 #Set Y Value second_label: add r18, r16, r17 #This is the instruction for X+Y=Z. Register 18 is the Z value mr r16, r17 #Copy Y's values over to X mr r17, r18 #Copy Z's value over to Y cmplwi r16, 0xFF #Compare X's value to 255 blt+ second_label #If less than (more likely to occur) continue the Fibonacci sequence by jumping to back to second_label b first_label #Once X equals 255, reset the entire sequence. Jump to first_label Raw ASM: 3A000000 3A200001 7E508A14 7E308B78 7E519378 281000FF 4180FFF0 4BFFFFE4 |