EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Change from 32 to 8 arithmetic in a security application

Started by Ulf Reiman September 11, 2006
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

Regards 
Ulf Reiman

Ulf Reiman wrote:

> 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. -- Thad
On 11 Sep 2006 04:09:24 -0700, Ulf Reiman wrote:
> 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 > Regards > Ulf Reiman
I think compiler will worry about that. There are instruction like add with carry and substract with cary which can make it possible.
Ulf Reiman wrote:
> 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 > > Regards > Ulf Reiman
was it 32 bit floating point?
Ulf Reiman wrote:
> 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 > > Regards > Ulf Reiman >
Huh? in C , asm, Pacal? 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.
On Mon, 11 Sep 2006 16:57:25 +0200, "Mad I.D."
<madid87-MAKNI-@yahoo.com> wrote:

>On 11 Sep 2006 04:09:24 -0700, Ulf Reiman wrote: >> 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 >> Regards >> Ulf Reiman > >I think compiler will worry about that. There are instruction like add with >carry and substract with cary which can make it possible.
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. Paul
"Ulf Reiman" <ulf.reiman@gmail.com> wrote in message 
news:1157972964.736720.118230@i3g2000cwc.googlegroups.com...
> 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 > > Regards > Ulf Reiman >
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. Cheers, Alf

Ulf Reiman schrieb:

> 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 >
Hello, 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. Bye

Memfault Beyond the Launch