Hi
I have a lot of ASM snippets and I am in the process of trying to recode most of them to C. It is a long and tedious process it seems to make sure they are identical and function identically.
Is there any scripts or tooling that can automate this process to rebuild the structural syntax and I relabel the global and local defines as needed after the process completes?
"It is a long and tedious process it seems to make sure they are identical and function identically."
Would it not be simpler, then, to just keep it as assembler and call it from 'C'...?
I've really just started to apply the C version of it because for me I like being able to look at it and since I'm going to be using a .net app to read data streams from the 8051, so that will help me keep the code dare I say "clean" between the two apps. I'm using an 89S8252 to make the job cleaner. Some of the asm is very specific to my MPU project that has various "modules" both wireless and serial.
I saw the C to asm that keil supplies, but does someone have a snippet of code that can show the execution of a C call to asm function.....I'm a little hazy.
So I guess I'm being a bit lazy to not want to go and recode the whole mess. My C is rusty since I haven't used it in 10 years since I was a Cherry Semiconductor and with everything else going on......well you know......;)
You are going to interface your embedded system with a .NET application, and you think you should punish the little embedded guy by forcing it to be programmed just as if it was a PC? May I remind you that this is a 8051 thread and not an ARM thread?
You normally don't write in assembler unless you have to, because of longer development times and higher maintenance costs. Are you sure that the original reasons for choosing assembler instead of C are not still valid?
To call assembly from C, you simply use the normal C syntax for a function call. This assumes, of course, that the assembly function was written using the C calling conventions.
If not, there's no way to call the function, because it wasn't designed to be callable from C. (You could hack some special cases such as void (void), or try to inline the call setup and hope the code generator doesn't interfere, but why?) If the assembly doesn't conform to Keil C calling conventions and isn't structured, then it will be hard for a tool to convert to C to any good effect. (It won't help to create a C program that simply apes the assembler line-by-line; if the tool cannot extract higher level control structures and meaningful identifiers, then the code won't get any more readable, and might be less.)
View all questions in Keil forum