Help me to convert assembly to c(or c++) language

Thread Starter

hijack911

Joined Dec 23, 2009
4
My porject is: " Automatic Room Light Controller with Visitor Counter using Microcontroller." I've made it already in assemby but I can't run it in C.

Please help me to convert assembly to C language!!! I'm very weak in C programming!:confused:
Thanks all!
 

Attachments

Papabravo

Joined Feb 24, 2006
22,111
It is always possible to transform C or C++ into assembly language. It is not possible in some cases to do the reverse.

My counter example is anything having to do with the carry flag. Since C and C++ have no semantics for dealing with a "carry" flag or a "borrow" flag, or an "overflow" flag any assembly program written to manipulate numeric quantities that involves these flags may or may not be translatable.

If you think about it for a minute there are many examples of irreversible operations.
 

Thread Starter

hijack911

Joined Dec 23, 2009
4
Out of curiosity, if it works as is, why does the code need to be translated to C?

How do your sensors work?
Thank to reply! But my advisor aks me to convert Assembly to C :(. I simulate a circuit on Proteus, it works very well. I mean that I replace sensor by switch(I'll press it to create 'pulse' to be considered people) for which delays to 0.2s. 0.2s is enough for people to cross sensors in reality.
 

Papabravo

Joined Feb 24, 2006
22,111
It will be easier to write the application in C and not worry about doing a literal connversion. The point is to learn C, as Bill said.
 

Papabravo

Joined Feb 24, 2006
22,111
Well what exactly are you looking for in the way of ideas?

For example, evaluating an expression involving addition, subtraction, multiplication, and division should be straightforward. Regular loops should be rendered as one of the three loop types:
Rich (BB code):
while(condition)
    statement ;
 
do
    statement ;
while (condition) ;
 
for(initial; termination; increment)
  statement;
Conditional execution is done with if...else... statements or a switch statement.

Probably your biggest challenge will be to redo irregular control transfers, often referred to as spaghetti code.
 

Thread Starter

hijack911

Joined Dec 23, 2009
4
Well what exactly are you looking for in the way of ideas?

For example, evaluating an expression involving addition, subtraction, multiplication, and division should be straightforward. Regular loops should be rendered as one of the three loop types:
Rich (BB code):
while(condition)
    statement ;
 
do
    statement ;
while (condition) ;
 
for(initial; termination; increment)
  statement;
Conditional execution is done with if...else... statements or a switch statement.

Probably your biggest challenge will be to redo irregular control transfers, often referred to as spaghetti code.
I implement in C step by step.
Thanks all and happy new year!. when i get a code C, i'll post it in forum where everybody can give me an advice for the best solution!
 
Top