creating 2D array for structers using Dynamic memory allocation.
Tuesday, 25 August 2015
Tuesday, 19 May 2015
8051 : ALP to copy value of R0 from bank0 to R0 of bank1, bank2, bannk3
Intels 8051 microcontroller having 128 bytes of user application RAM and an extra 128 bytes as SFR area. This RAM is divided into three1) Register banks
2) Bit and Byte addresable area
3) Scratch Pad RAM
The register bank is again divided into register bank0 (RB0),register bank 1 (RB1), register bank2(RB2) and register bank3 (RB3). Each register bank having registers R1,R2,R3,R4,R5,R6,R7.
But at a time one register bank is accessible. Either RB0 or RB1 or Rb2 or RB3. That if we are using R0 from RB0 we are restricted to use the R0 from rest of the banks. The RB0 is ranging from address 0x00 to 0x07, RB1 is from 0x08 to 0x10 , RB2 is from 0x10 to 0x17 and RB3 ,0x18 to 0x1F.
Or using the PSW register2) Bit and Byte addresable area
3) Scratch Pad RAM
The register bank is again divided into register bank0 (RB0),register bank 1 (RB1), register bank2(RB2) and register bank3 (RB3). Each register bank having registers R1,R2,R3,R4,R5,R6,R7.
But at a time one register bank is accessible. Either RB0 or RB1 or Rb2 or RB3. That if we are using R0 from RB0 we are restricted to use the R0 from rest of the banks. The RB0 is ranging from address 0x00 to 0x07, RB1 is from 0x08 to 0x10 , RB2 is from 0x10 to 0x17 and RB3 ,0x18 to 0x1F.
So here utilizing the addresses.
.
Sunday, 17 May 2015
Linux : executing multiple commands from command line
Command line argument is used to giving input to our prgrame at load time. Using this simple code we can execute multiple commands. Here i used exec family of functions to execute each commands. Whenever we are using using exec family of functions try to execute the exec function in child process.
Note : How to rrun this code from terminal
$ ./a.out "ls;pwd;cal"
$ ./a.out "ls;pwd;cal;umask;ps -e"
Note : How to rrun this code from terminal
$ ./a.out "ls;pwd;cal"
$ ./a.out "ls;pwd;cal;umask;ps -e"
Linux : Non local goto
In programming goto is used to skip some statements of the code/ to make a loop. If we are setting the label above and calling label below, then it will act as a loop. But if setting the label below and calling the label above , so we can skip some staments. This goto local tothe function only.
Using non-local goto we can jump between functions. Here setting the label is done by using one function setjmp(), calling the label using longjmp().
C : Implementation of printf()
printf() is one of the variable argument list function. A variable argument list function is that it can take varying number of arguments. printf() needs min of one fixed argument, that should ba a string. This programe is a small implementation of printf(). Here i am not writing any driver level programme. Using C functions only the code is written.
C : Stack implementation using array
Stack is one of the data structure. Follows one approach known as LIFO(Last In First Out). Stack palys vital role in programming, especially in recursive programming. Whenever a programe is loaded into RAM four blocks of memory is created (stack, heap, code, data). Return address, Formal arguments, are stored in this stack section. So this programe's aim is to make a small prototype of stack.
Saturday, 16 May 2015
C : repalcing one word with another word in text file
This programe repalces any word in the text file with word given by user .
C : Implementation of atoi() function.
atoi() function converts string into integer. String should be pass to the atoi() as an argumant.
Prototype: int atoi(const char *arg);
Prototype: int atoi(const char *arg);
C : Implementation of atof() function.
atof () functio converts its argumnt arg to double.
Prototype: double atof(const char *arg)
Prototype: double atof(const char *arg)
Friday, 15 May 2015
Linux : Search link between two files.
There are two types of links are present bet ween files. One is Hard link and another one is Soft link.
command to creat hard link file :
$ln file_name1 file_name2
Note: the file_name1 should create using vi editor or using cat command before making the link.
command to make soft link files/symbolic link files.
$ln -s file_name1 file_name2
command to creat hard link file :
$ln file_name1 file_name2
Note: the file_name1 should create using vi editor or using cat command before making the link.
command to make soft link files/symbolic link files.
$ln -s file_name1 file_name2
Thursday, 14 May 2015
Shell Script: To find the factorial of a number
To execute this script in bash shell must and should provide the execute permision. To give execute permission in user level use the command:
If you are using sh shell no need of providing permission
chomd u+x file_name.sh
echo "enter the number" read n fact=1 while [ $n -gt 0 ] do fact=`expr $fact \* $n` n=`expr $n - 1` done echo "factorial=$fact"
Subscribe to:
Posts (Atom)