X16Community / x16-rom

Other
43 stars 27 forks source link

[KERNAL] PRIMM: Add 65C816 native mode support and optimize the 65C02 code to use (zp) instead of (zp),y with y = 0 #352

Open Fulgen301 opened 4 weeks ago

Fulgen301 commented 4 weeks ago

PRIMM is the only KERNAL library function left that uses abs,x addressing for stack access, thereby not working with a 65C816 in native mode where the stack page might have been moved. This PR adds an implementation that uses the 65C816's stack-relative addressing to work with arbitrary stack pointers; it also optimizes the 65C02's code path by changing the unnecessary (zp),y addressing modes with y = 0 to (zp), leaving y untouched.