Hi! How do a change a security application done with 32 bits arithmetic to
8 bits arithmetic. It was build for a PC, but a want to use it in a microcontroller. What do I need to change, think about.....? The application is done in C
Hi! How do a change a security application done with 32 bits arithmetic to
8 bits arithmetic. It was build for a PC, but a want to use it in a microcontroller. What do I need to change, think about.....? The application is done in C
The biggest issues are probably determining the amount of memory you require, what the speed requirements are, what the I/O requirements are, and how you are going to build a system with a microcontroller.
If the C code was written with portability in mind, compiling it for a
8-bit microcontroller may be straight-forward. There are many possible issues to be addressed if the code was not written with portability in mind. Your I/O will change, though.
If 32 bit math is required, You must do it as 32 bits. Otherwise, Look at all equations an variables and determine the minimum size the can be while still giving the correct results.
You should also check how the compiler for the 8 bit processor stores values larger than 8 bits. If it uses big-endian notation and since PC programs use little-endian notation, there may be some big/little endian problems, if overlapping data structures (such as unions) are used.
Why not just do it in a 32 bit microcontroller. The Philips ARMS for instance start at under US$2 in quantity and you can get one with 512K of Flash for under US$5.
you should look first for the supported data types which may be used with this compiler and microcontroller. Are there only 8 bit integer, or are there also 16 or even 32 bits integer? Requires the application only 32 bit unsigned integers or also signed ones? What operations are used and are they supported? Add, subtract, multiply, divide, and, or, shift...?
If necessary you may define small functions for all needed operations with 32 bits. It may be easier in assembler to use the add with carry instructions, but you should write assembler subroutines which may be called from c code.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.