![keil c51 keil c51](https://gd1.alicdn.com/imgextra/i3/0/O1CN017ma7oU28klaA2UVHe_!!0-item_pic.jpg)
The compiler can use this information to optimize memory access. This is because the memory area accessed by the pointer is known at the compile time rather at run-time.
KEIL C51 CODE
The Code generated by keil C compiler for memory-specific pointer executes mroe quickly than the equivalent code generated for a generic pointer. Memory-Specific pointers can be stored using 1 byte (for idata, data, bdata and pdata pointers) or 2 bytes (for code and xdata pointers). Pointer to character stored in Code memoryĪs Memory-Specific pointers are defined with a memory type at compile time, so memory type byte as required for generic pointers is not needed. Pointer to character stored in External Data Memory. Pointer to character stored in Data memory Memory specific pointers are defined along with memory type to which the pointer refers to, for example: Generic pointers maybe used to access any variable regardless of its location. The first byte is the memory type, the second byte is the high-order byte of the offset, and the third byte is the low-order byte of the offset. Generic pointers are always stored using three bytes. Generic Pointers are declared same as standard C Pointers as shown below: Keil C provides two different types of pointers: In addition, keil C extends the operatability of pointers to match with the 8051 Controller architecture. Pointers in keil C is are similar to that of standard C and can perform all the operations that are available in standard C. variables are accessed using DPTR.ĭepending on our hardware configuration we can specify the momory models as shown below: Compact Variables in one page, maximum 256 variables (limited due to addressing scheme, memory accessed indirectly using r0 and r1 registers) large All variables in external ram. Small All variables in internal data memory. There are three kind of memory models available for the user: Use the interrupt vector address in the following table to determine the interrupt number. C51 compiler supports interrupt functions for 32 interrupts (0-31). Funtion named "function" uses register bank 2 while executing its codeĭescription: This keyword will tells the compiler that function described is an interrupt service routine. 16-bit special function register starting at 0x82ĭescription: This keyword is used to define register bank for a function. Special function register with name Port1 defined at addrress 0x90ĭescription: This keyword is used to define a two sequential 8-bit registers in SFR memory. Special bit with name Port0_0 is defined at address 0x80ĭescription: sfr is used to define an 8-bit special function register from sfr memory. variable x will be stored at location 0x30ĭescription: This keyword is used to define a special bit from SFR (special function register) memory.
![keil c51 keil c51](https://i0.wp.com/technobyte.org/wp-content/uploads/2020/05/keilsetup-2.png)
![keil c51 keil c51](https://community.arm.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/471/Screenshot_5F00_2020_2D00_07_2D00_03_5F00_14_2D00_23_2D00_55.png)
example:ĭescription: This keyword is used to store a variable on a defined location in ram. Unsigned char code str="this is a constant string" ĭescription: This keyword will store the variable in paged data memory. So instead we will make use of the keyword "code" as shown in example below. Wasting ram for such string will be foolish thing. Lets say you have a big string which is not going to change anywhere in program. example:ĭescription: This keyword is used to store a constant variable in code memory. X ^ 0 = 0 //0th bit of variable x is clearedĭescription: The variable will be stored in external RAM memory of controller. each bit of the variable x can be accessed as follows
![keil c51 keil c51](http://downmsn.ycpaint.com/20191107/ztpafnojfq3.jpg)
example:ĭescription: The variable will be stored in bit addressable memory of controller. Keil C51 compiler adds few more keywords to the scope C Language:ĭescription: The variable will be stored in internal data memory of controller. As we are going to use Keil C51 Compiler, hence we also call it Keil C. So Its important that you know C language for microcontroller which is commonly known as Embedded C. And most of the time its not easy to buld an application in assembly which instead you can make easily in C. The use of C language to program microcontrollers is becoming too common.