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.
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
637
Reputation
1,272
Reaction score
88
Trophy points
1,328
Location
USA
Activity points
33,176
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 ... ?
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,416
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..
 

waterman

Member level 5
Joined
Mar 27, 2002
Messages
80
Helped
2
Reputation
6
Reaction score
2
Trophy points
1,288
Activity points
562
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.
 

gam

Advanced Member level 4
Joined
Mar 25, 2004
Messages
115
Helped
8
Reputation
16
Reaction score
4
Trophy points
1,298
Activity points
1,158
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top