# how to creat a assemble and c program in keil software

Status
Not open for further replies.

#### shivachellam

##### Newbie level 6
how to write assembly code in keil

hi
i am studying about 89c51 micro controller now i started to program .most peoples said keil software is good to program in 89c51 but i dont know how to write a assemble and c programs help me and if any books are available to know about keil software plz tell thank u very much

#### mezo

##### Member level 5
how to execute asm programs in keil software

Well, shivachellam
I've used Keil compiler it's a good one, you can write programs in C or Assembly, or either a combination of the two. i'll tell you the steps to create a new assembly project

I've printed screen the steps, and attached it to you on a word document. you just download it and carry on step by step.

Amruta.d.s

points: 2

### Amruta.d.s

points: 2

#### shivachellam

##### Newbie level 6
keil software + example program in c

thank u very much if u can give any sample and simple code in c & assemble it will very useful to me
thank you

#### mezo

##### Member level 5
variable location for keil

well, shivachellam
you will find examples at the help of the compiler itself

#### GetDeviceInfo

keil two assembly files assembling

As well, most suppliers of controllers supply basic C code for onboard functions, ie; timers, converters, uarts, etc.

Atmel will supply both assembly and C code for it's product line, as well as Keil libraries for device specific compiling.

Amruta.d.s

### Amruta.d.s

points: 2

#### samx

##### Newbie level 4
compiling c programs with keil

Hi People........
I am writting an application in C.In this application I have include some assembly instructions(for manupulating the stack).I tried this

including the asm code in between the #pragma directives.
#pragma asm

ASM code
#pragma endasm
When I am compiling this code( keil compiler u2),its getting compiled and generating the hex file.But when run this through the

simulator(KEIL simultor) the control is transferring to NOP location(I mean it not working or running).
I have included
C51S.LIB: Small model library without floating-point math.
C51C.LIB: Compact model library without floating-point math.
C51L.LIB: Large model library without floating-point math.
C51FPS.LIB: Small model library with floating-point math.
C51FPC.LIB: Compact model library with floating-point math.
C51FPL.LIB: Large model library with floating-point math.
to the source group and Generate Assembler SRC File and Assemble SRC File enabled (both are ticked).
Please suggest me something so that I can proceed further.

#### GetDeviceInfo

assembly program in c keil

$(for manupulating the stack).$

any guesses?

Last edited by a moderator:

#### nikhil_damle

keil software program

U CAN FIND THE EXAMPLES IN THE COMPILER HELP FILE OR ON WWW.KEIL.COM

#### samx

##### Newbie level 4
keil pragma - optimize

Hi,
Actually when ever a function is called, all local variable should be created on to the stack and then proceed for executing the function body.

But in keil compiler, when I call a function variables local to the function are not created onto the stack.There are creating some where in the RAM.

But in my application I need to save all the variables values.

Is there any option in keil to allow the controller to create local variables on to the stack?

Could anyone help me.

#### GetDeviceInfo

sample programs keil programs

In your device configuration, try different variable/code size options. I noticed in prior projects as well that code would jump unexpectedly to a nop location. Changing the code size to 'large' corrected that.

In Keil you can include optimizing directives. As a default, Keil utilizes registers for variables, then data locations. By including a optimzing directive of level 2, you can declare variables to the stack. Check Keil help for 'optimizing'