Adsense

Write Embedded C code to perform the arithmetic and logical operations for integer data type on FRDM KL25Z.

Main C file

//-Global definition area of the C file-
#include "ALops_func.h"
//include the user defined header file containing adder function
//---main of the program---
int main(void){
volatile unsigned int temp0=0x9F00,temp1=0X6A0,temp2=0x0;
//define 13 variable of the data type long
volatile unsigned int temp3=0x0,temp5=0x0,temp6=0x0,temp7=0x0;
volatile unsigned int temp8=0x0,temp9=0x0,temp10=0x0,temp11=0x0;
volatile unsigned int temp12=0x0;
volatile unsigned long long temp4=0x0;
//define a variable of the data type long
temp2=add2(temp0,temp1);
temp3=sub2(temp0,temp1);
temp4=mul2(temp0,temp1);
temp5=div2(temp0,temp1);
temp6=rem (temp0,temp1);
temp7=and2(temp0,temp1);
temp8=or2(temp0,temp1);
temp9=xor2(temp0,temp1);
temp10=inv(temp0);
//left shift by 2 bit
temp11=left_shift(temp0,2);
//right shift by 2 bit
temp12=right_shift(temp0,2);
return(0);
}
 

// now you need to create header file same like C file you are creating
procedure: goto new file -> create new file -> paste code below mentioned -> save it with name ALops_func.h -> header file is ready to use



User defined header file

//Function defined in global definition area

unsigned int add2(unsigned int ,unsigned int );
unsigned int sub2(unsigned int ,unsigned int );
unsigned long long mul2(unsigned int ,unsigned int );
unsigned int div2(unsigned int ,unsigned int );
unsigned int rem (unsigned int ,unsigned int );
unsigned int and2(unsigned int ,unsigned int );
unsigned int or2(unsigned int ,unsigned int );
unsigned int xor2(unsigned int ,unsigned int );
unsigned int inv(unsigned int );
unsigned int left_shift(unsigned int ,unsigned int );
unsigned int right_shift(unsigned int ,unsigned int );

/*starting of the header file*/
#if!defined(ALops_func_h_)

/*Check if memory map has not been already included */
#define ALops_func_h_
//-bodyofheaderfile-
//addition of two unsigned integer
unsigned int add2(unsigned int x,unsigned int y){return(x+y);}
//subtraction of two unsigned integer
unsigned int sub2(unsigned int x,unsigned int y){return(x-y);}
//multiplicationof two unsigned integer
unsigned long long mul2(unsigned int x,unsigned int y){return(x*y);}
//divisonoftwo unsigned integer
unsigned int div2(unsigned int x,unsigned int y){return(x/y);}
//Modulus(remainder) of two unsigned integer
unsigned int rem (unsigned int x,unsigned int y){return(x%y);}
//AND of two unsigned integer
unsigned int and2(unsigned int x,unsigned int y){return(x&y);}
//OR of two unsigned integer
unsigned int or2(unsigned int x,unsigned int y){return(x|y);}
//XOR of two unsigned integer
unsigned int xor2(unsigned int x,unsigned int y){return(x^y);}
//invert the unsigned integer
unsigned int inv(unsigned int x){return(~x);}
//left shift by Y bits
unsigned int left_shift(unsigned int x,unsigned int y){return(x<<y);}
//right shift by Y bits
unsigned int right_shift(unsigned int x,unsigned int y){return(x>>y);}
//--endofthebody--
#endif

2 comments:

  1. you need to modify this code for the different data types like char , short integer and long long.

    ReplyDelete
  2. Slot Machines - Hollywood Casino - JT Hub
    Slot Machines. 여주 출장샵 Hollywood Casino. Hollywood Casino. Hollywood 안산 출장샵 Casino. Hollywood Casino. 의왕 출장마사지 Hollywood Casino. Hollywood Casino. Hollywood Casino. 의정부 출장마사지 Hollywood 과천 출장샵 Casino. Hollywood Casino. Hollywood Casino

    ReplyDelete

Write a ARM cortex M0+ assembly language code based on arithmatc and logical instructions.

 Problem 1: Implement following code conversions to convert binary no 0x89ABCDEF(32-bits) into a) BCD (64-bits)   b) Gray (32-bits) Problem...