NefMoto

Technical => Reverse Engineering => Topic started by: pjotrs on February 04, 2026, 12:12:59 AM



Title: asm help needed for me7.5 launch does not work?
Post by: pjotrs on February 04, 2026, 12:12:59 AM
I have issue:
   im trying to rewrite asm launch + NLS to C (why? so i could easily customize it), and kinda works, the structure is there BUT, the code does not run.

Compiled the C code and the structure looks okay, changed r5 registers that compiler made to r9 (i tought it was the issue -  that r5 is overrided).. - not the case.

then did a lot of testing, nothing helps... maybe the exts, extp issues?

can you please take a look?

i added working and not working asm files - image in attachment, thank you in advance...

Not working (my C compiled ASM)..
https://e30.dev/asm/notworking.jpg

Working:
https://e30.dev/asm/working.jpg

thank you!


Title: Re: asm help needed for me7.5 launch does not work?
Post by: fknbrkn on February 04, 2026, 03:42:48 PM
the main issue is the weirdo memory mapping with extp imo, you have the stock code why not to use it?

extp/exts on DPP-covered memory areas are not necessary

also this code is super complicated, keep in mind this 24-40mhz beast has a limited resources  ::)
entry point of 8 instructions could be done with 3:

movb rl4, 08A45h ; 0x380A45 tmot
cmpb rl4, 07E79h ; 0x817E79  minimal tmot map i believe, original code uses exts here but its not necessary here as its at DPP page 0x205
jmpr cc_ule, loc_meow


moreover c167 doesnt have callee-saved registers which means.. uh.. lets say if register getting its value before call to your procedure and after that its value examined then you cannot touch it in your routine. stack could helps here but imo its always better to not touch the stack without a reason

no reason to use C here as it takes more time than just pure asm

also 380BB5 is a tsrldyn not a 'toggle'


Title: Re: asm help needed for me7.5 launch does not work?
Post by: pjotrs on February 04, 2026, 04:29:29 PM
the main issue is the weirdo memory mapping with extp imo, you have the stock code why not to use it?

extp/exts on DPP-covered memory areas are not necessary

also this code is super complicated, keep in mind this 24-40mhz beast has a limited resources  ::)
entry point of 8 instructions could be done with 3:

movb rl4, 08A45h ; 0x380A45 tmot
cmpb rl4, 07E79h ; 0x817E79  minimal tmot map i believe, original code uses exts here but its not necessary here as its at DPP page 0x205
jmpr cc_ule, loc_meow


moreover c167 doesnt have callee-saved registers which means.. uh.. lets say if register getting its value before call to your procedure and after that its value examined then you cannot touch it in your routine. stack could helps here but imo its always better to not touch the stack without a reason

no reason to use C here as it takes more time than just pure asm

also 380BB5 is a tsrldyn not a 'toggle'

Thank  you for your response!

I "fixed" the reset timer i will test it one more time, if nothing, then ill use the asm! (and i will report if the main issue was extp (for now ill keep (cause compiler does it automatically) it to make sure))

About the

3 instructions instead of one, the compiler does this, i think if i tweak the settings it might produce better result, but you are totally right. (i want to use C, cause it's easier for me to customize the code in future)

good catch on tsrldyn, thanks ill update the comment! :D


Appreciate the help man, will update with results!


Title: Re: asm help needed for me7.5 launch does not work?
Post by: pjotrs on February 05, 2026, 10:24:44 AM
Thank  you for your response!

I "fixed" the reset timer i will test it one more time, if nothing, then ill use the asm! (and i will report if the main issue was extp (for now ill keep (cause compiler does it automatically) it to make sure))

About the

3 instructions instead of one, the compiler does this, i think if i tweak the settings it might produce better result, but you are totally right. (i want to use C, cause it's easier for me to customize the code in future)

good catch on tsrldyn, thanks ill update the comment! :D


Appreciate the help man, will update with results!


Thank you for the tips! I went the ASM way.