Thread: Tip on How to convert C++ code to kiel to use further in it for microcontrollers.

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    5

    Tip on How to convert C++ code to kiel to use further in it for microcontrollers.

    Help me on how can I, actually I am having AES encryption code which is written in c++, I have three files , aes code header, its cpp file and the main test file that takes the input data and encrypt by calling the function of encrypt from header file having it.

    I need to use it in kiel to hex ready for the controller, will it work if I put this code with current code that receive the data from other device or say controller, and convert it to hex file for controller?


    HOpe you getting me, help please.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So just rename it to aes.c, compile it and see what happens.

    I mean, encryption just takes a block of data, turns in into another block of data, using a key.
    It's hard to imagine just how much C++ sugar could be coating something so simple.

    Or you could just hit google again and try and find some C code instead.
    Oh look - now wasn't that easy - AES Code
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    5
    Hello salem

    surfing to some of the posts in this forum I found you helping alot. actually as much I know, the code I use is working fine. but I am asking for will the same code work on kiel or I have to change it, mean any syntax change or some how changes like...? as keil can make hex file for me which I can later when required load to ucontroller.

    Thank you for you previous post. and expecting more as well. please don't mind my questioning again and again.

    another thing also. can you suggest me any specific book for learning keil and also for microcontroller which you think is easy and best to learn from.

    Thank you.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Quote Originally Posted by engr.haris86 View Post
    I am asking for will the same code work on kiel or I have to change it, mean any syntax change or some how changes like...?
    Why don't you test it and come back with the errors you get so we can help you with those? Keil looks like any other C compiler and encryption is just pushing bytes around, any C compiler should be able to do this.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    5
    Hello All,

    I think I am wrong with my interpretation. what actually I want to do is that. I am having the code. code working working fine with c++, all I want to know what actually will I have to add change with to use it in a micro-controller?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well why don't you start with changing nothing at all and see how far you get.
    C and C++ are portable languages, which means if the original author made a decent job of it, then it stands a pretty good chance of working "out of the box".

    > all I want to know what actually will I have to add change with to use it in a micro-controller?
    And what in your posts so far would allow us to make such a statement.
    - We can't see your code
    - We can't see your micro controller
    - We don't know which controller you have (there are 1000's of them).

    You've only mentioned kiel as a compiler.

    Let me ask another question - have you written ANY code at all for this controller, say something really simple like flash LED's, echo characters on serial line and so on?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    5
    This is what actually I want to know on what should I do, and any reference on how to do. all I want to do is take this code. put it in the mic controller, and to do receive the data at one pin and encrypt it and send it to another pin as out put... I want to use it as the way describe. can any one suggest me how to do them. mean I don't know how to programm for controller. for instance let say I am using AT89C51, I mentioned kiel as the compiler just because till now I have seen a project in which kiel was used and yet didn't knew for the difference of kiel compiler with others.

    and offcourse I have to learn this part my self , but all I can do is go for books to study from or any other source like internet to learn from....

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you've never programmed a micro-controller before, then it's baby steps for a while at least. You're a good few weeks from finishing this task. You need to take things really slow (code development wise), even down to the point of only writing one line at a time and testing it to make sure it still works.

    Check out the manufacturer website and read as much as you can.
    Atmel Corporation - Atmel AVR 8- and 32-bit Microcontrollers

    One valuable source of information would be any "application notes" which show you how to implement very simple ideas which you can build on.
    In your case, putting a switch across one pin, and an LED across another pin, then writing some code to copy the state of the switch pin to the LED pin would mimic the basic behaviour of what it is you want to do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    5
    ok bro , let me c them and come back to continue with what I want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comment each line and convert this C++ OOP code into C++ code.
    By Shayaan_Mustafa in forum C++ Programming
    Replies: 3
    Last Post: 01-03-2011, 01:23 PM
  2. Microcontrollers in C
    By zyxx_66 in forum C Programming
    Replies: 4
    Last Post: 02-22-2009, 11:55 PM
  3. Programing microcontrollers in c
    By gorabhat in forum C Programming
    Replies: 2
    Last Post: 09-09-2008, 10:40 AM
  4. Replies: 14
    Last Post: 04-01-2008, 02:23 AM
  5. C Programming for Microcontrollers
    By CB4 in forum C Programming
    Replies: 4
    Last Post: 03-07-2005, 08:34 AM

Tags for this Thread