“Hello world” with Keil and AT89C51

Hi friends. many of my friends requested me to show me how to start with keil compiler.

Keil does not have  much inbuilt functions, so you hav to write most of the codes yourself. The header file only defines the PORT adresses.  you may check it in C://Program files/Keil/asm51/inc folder there must be a number of files for every microcontroller that it supports.

that contains lines like

sfr P0 0x99;

sfr P1 0x98;

sbit TCON 0x34;   …..

hello world in Microcontrollers is the ” LED Blink ” program. Here writing “Hello world” is very complex(not suitable for a beginner). So you have to first learn about handling the I/O ports.

Unlike the 8085 uP have commands like IN OUT, here we don’t need any IN/OUT commands. with the same MOV commands we can send some DATA to the PORTs and reversly can read from the PORT.

In C (here am talking about Keil compiler only) we can send data by simply writing A assignment statement like


it means all pins of PORT0 is set high. but the compiler will say undefined P0 if haven’t added the reg51.h i.e. the line #include<reg51.h> at the top of the code.

the program will be like this

while(1) {

Leave a Reply