![]() |
|
T9000 HL reg issue - Printable Version +- Freeplaytech Forum (https://forum.freeplaytech.com) +-- Forum: Neo Geo Pocket (https://forum.freeplaytech.com/forumdisplay.php?fid=1) +--- Forum: Software Development (https://forum.freeplaytech.com/forumdisplay.php?fid=4) +--- Thread: T9000 HL reg issue (/showthread.php?tid=5494) |
T9000 HL reg issue - KanedaFr - 07-07-2025 While debugging my game, I found 1 strange issue. I had a method to print an integer which starts like this : Code: void VDP_printInteger(u8 planeId, u8 xpos, u8 ypos, u8 palId, u16 number, u8 length, u8 leading){looking at the code produced, it sets HL to 0x9000, nothing wrong here later on my game, I do a collide test Code: unsigned char testCollide( ){this will produce a LD L,1 nothing wrong here too my problem is with this code Code: if (testCollide( ) == 1) it will produce a CP HL, 1 not a CP L, 1 if I call VDP_printInteger BEFORE testCollide, HL = 9001, and so the test is "wrong" I solved the issue using adecl, to force cleaner use of register XWA, XBC, XDE and XHL. but what should be done to avoid that ?! Unless using adecl on every function using HL (sic!), I see no way to avoid this..... what is even worst is that another similar test, with same return type if ( testCollideNPC() == 1) works like a charm! I found a "fix" but I didn't find the reason so if anyone had an idea, let me know ![]() Note: I'm actually trying to export the asm of every C file, to see where the problem happens on other methods but -la doesn't since to work..... RE: T9000 HL reg issue - KanedaFr - 07-07-2025 The second method (which works) generates a CP L, 1 I do not understand why THIS one generate a CP HL, 1 .... RE: T9000 HL reg issue - KanedaFr - 07-07-2025 I FOUND IT ! I forgot to include the header file where testCollide is declared as unsigned char testCollide Since the compiler didn't find it at pre processor time, it handles it by default to int. I'm now looking for the option to generate a warning/error in this case because it will certainly happens again...and it costs hours to find the real reason !!! edit : -w3 is the one to generate a Undefined return type in 'xxxx' warning -w1 and -w2 are too soft.... |