Hi,
I have a working old code in rom 32k, I added ram code at the upper 32k and I set the hw to start form the new ram at 32k.
I want to address old function from the new ram code without modify the old project.
once I compile the project code the hex output is not the old rom hex with the new ram code.
rather it recompiled the old code to optize it and I have a new hex that is not like the old rom hex with the new additions.
The thinng is that I need to address the old code function (fixed hex in rom).
what can I do?
regards, dan
How/when do the program jump into RAM? How will the original CRTL copy be initialized? How will all original global variables be initialized? How will you sort out what global addresses to fill with parameter values before you call a function in the OTP?
You are conceptually trying to rewire a kitchen food processor for mixing concrete for a new hospital. Or adding a big-block chevy engine to a normal mountainbike. Or trying water cooling and kevlar strengthening of a couple of bookshelf speakers for use as PA system on a large outdoor event. It's not looking good. Spend a couple of hundred or thousand hours and you will get the idea that the concept is no good.
Of course you will have to play with assembler. But assembler will not be enough, unless the OTP code just happens to have the correct subdivision to allow you to patch in. It most probably does not, since you are trying a reverse of what the OTP code was originally designed for. There is a huge difference between calling a patch function and adding a new program that tries to call back into the original code.
Your hardware is cheap compared to the cost of trying to get a *** solution to work for you. And every time you need to make changes, your *** solution will fail and require you to do more reverse engineering to try to fix it again.
How/when do the program jump into RAM?
there is the clincher.
with an unchanged ROM, that currently does not call the RAM as you have stated "I have a working old code in rom 32k" a) the reset vector will jump to somewhere in the ROM b) the ROM will not call the RAM
so with an unchanged ROM, previously unaware of the RAM it is impossible
Erik
As mentioned above, working in ram and using existing code is a new project to decide on.
The approach is to create a new hex file with only hooks call for used function, then add the lower hex to create a new hex file with both application.
once done, to start going every register used in the old code needed functions and save it un touched, next to update the asm in the new project to fit.
Yes it a long way to do manually and in asm ..
Is there any other creative way to do it ?
thanks, dan
In his case, it should be possible, if that original ROM code expected to find code fragments in RAM to replace one or more of the functions in the ROM.
But it is a conceptually large difference between having a fixed program call a couple of replacement functions, and having the replacement functions becomming the new program and try to call back.
With two programs, two sets of global variables must be allocated, given initial values, ...
Next thing is that there will be two sets of CRTL functions for the same operation since the compiler will try to build a new program for stand-alone use. But if there are two copies of the same CRTL function, then there can be huge problems with the state of the two sets of global variables used by the two sets of CRTL functions.
One things leads to another in an every faster spinning spiral of disaster. Somewhere, one or more people thinks they save time/money by following that spiral.