Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

varible initialisation in 8051..

Status
Not open for further replies.

sacrpio

Member level 3
Joined
May 24, 2004
Messages
56
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
500
How variables are initialized when we powered On a microcontroller. My code is writen in C. Actually I am interested in that what is the process of var initialisation in 8051.
 

C compilers usually generate a startup routine that initializes various things, and then calls your main(). The startup routine varies from one compiler to another. Its inner details shouldn't matter to your C program.

Maybe if you explain why this is interesting to you ... ?
 

I would ecourage everyone to go first through assembler and then to C..C+...and so on.. because in assembler you will learn how to control/use every single bit within thid gismo..
 

Use keil as the example.

The compiler insert a default startup routine in your C code, if you
do not specify your own. The IDATA will be cleared to 0x00, during
the startup process. (See STARTUP.A51)

If you don't like this, you could change the source code to whatever
you like.
 

Of course, if you want to understand how a certain function is implemented, you need to be familiar with the assembler. This is the lowest you get to the workings of the MCU.

For variable initialization (Let's say register C initialized with value 0x10 (hex)) the following PIC assembly code (2 instructions) would be implemented:

Movlw 0x10 ;Move literal value 0x10 to accumulater or working register
Movwf C ;Move the accumulator content to register C (must be defined previously the address of C)

Which is equivalent to the following C code line:
C=0x10;


Gam
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top