Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; The 65816 SNES code that is being JIT compiled:
- ; $00:8000: LDA #$5A
- ; $00:8002: LDX #$08
- ; loop:
- ; $00:8004: STA $0003,x
- ; $00:8007: DEX
- ; $00:8008: CPX #$01
- ; $00:800A: BNE loop
- ; $00:800C: STP
- ; Which basically just writes 7 bytes of 0x5A into memory at $0005-$000B
- ;--------------------------------
- ; The following functions are the result of the JIT compilation, which ran like this:
- ; Generate ADDR_008000_MX
- ; Run ADDR_008000_MX | Initial LDA+LDX and 1st loop
- ;
- ; Generate ADDR_008004_MX
- ; Run ADDR_008004_MX | 2nd loop
- ; Run ADDR_008004_MX | 3rd loop
- ; Run ADDR_008004_MX | 4th loop
- ; Run ADDR_008004_MX | 5th loop
- ; Run ADDR_008004_MX | 6th loop
- ; Run ADDR_008004_MX | 7th loop
- ;
- ; Generate ADDR_00800C_MX
- ; Run ADDR_00800C_MX | STP (stop)
- ;--------------------------------
- ; This function runs the first two instructions and the first loop until the branch.
- ; We can optimize things, because the first loop always runs with A=0x5A and X=0x08.
- ; Other things are optimized too, e.g. LDA, LDX and DEX all affect the N and Z flags of the P register,
- ; but those computations are all removed because their results are not needed before CPX overwrites them all.
- entry:
- store i8 90, ptr %6, align 1 ; Execute STA of STA $0003,x | A is always 0x5A=90 here, that's why we can hardcode the value
- store i16 -32764, ptr %0, align 2 ; Write 0x8004 to PC and quit block because we reached a branch instruction
- ret void
- }
- ; This function runs the loop.
- ; Since A and X can be anything here, we can't optimize things so much.
- entry:
- ret void
- }
- entry:
- ret void
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement