Posts

Micro

 LXI H, D020H ; Step 1: HL points to starting address         MVI C, 0AH ; Step 2: count = 10 bytes         MVI B, 00H ; Step 3: B = even count = 0         MVI D, 00H ; Step 4: D = odd count = 0 NEXT: MOV A, M ; Step 5: Get byte into accumulator         ANI 01H ; Step 6: Mask LSB → check even/odd         JNZ ODD ; If result ≠ 0 → odd number EVEN: INR B ; Step 7: increment even counter         JMP CONTINUE ; Step 8: skip odd part ODD: INR D ; Step 9: increment odd counter CONTINUE:         INX H ; Step 10: move to next memory         DCR C ; Step 11: decrease count         JNZ NEXT ; Step 12: repeat until 10 bytes processed       ...

Bit stuffing sender

 #include <stdio.h> void main() { char str[100],ptrn[7]="011111",dest[100]; int i,j=0,k=0,c=0; printf ("Flag is 0111110."); printf ("\nEnter The Data : \t"); scanf ("%s",str); while (ptrn[j]!='\0') { dest[k]=ptrn[j]; j++; k++; } dest[k]='1'; k++; dest[k]='0'; k++; j=0; for (i=0;str[i]!='\0';i++) { if (str[i]==ptrn[j]) { dest[k]=str[i]; k++; c++; j++; if (c==6) { dest[k]='0'; c=0; j=0; k++; } } else { dest[k]=str[i]; j=0;c=0; k++; if (str[i]==ptrn[j]) { j++;c++;  } } } j=0; while (j<=5) { dest[k]=ptrn[j]; j++; k++; } dest[k]='1'; k++; dest[k]='0'; dest[k+1]='\0'; printf ("sending Data .... %s",dest); } 

Parity bit sending receiving side

 #include <stdio.h> #include <stdlib.h> int checking(char *data) {  int i=0,num;  while (data[i]!='\0')  {  num=data[i]-48;  if (num=='0'||num=='1')  {  i++;  }  else  {  return 0;  }  }  return 1; } int main() {  char data[40],rdata[40];  int i=0,count=0,check;  printf("Enter the data : \t");  scanf ("%s",data);  check=checking(&data[0]);  printf ("%d is num",check);  if (check==0)  {  printf ("Error.....\nEntered Data is Wrong");  return 0;  }  else if (check==1)  {  printf ("Entered Data is Correct.");  }  while (data[i]!='\0') {   if (data[i]=='1')  {  count++;  i++;  }  else  {  i++;  } }  if (count%2==1)  {  data[i]='1';  data[i+1]='\0';  printf ("\nData to be sent : %s",data);  } ...

Bit stuffing recever

 #include <stdio.h> #include <string.h> void main() {  char str[100],data[100],ptrn[7]="011111";  printf ("Enter the data : \t");  scanf("%s",&str);  int i,j=0,k=0,c=0;  printf ("%d",strlen(str));  for (i=8;i<strlen(str)-8;i++)  {  if (str[i]==ptrn[j])  {  data[k]=str[i];  k++;  j++;  c++;  if (c==6)  {  i++;  j=0;  c=0;  }  }  else  {  data[k]=str[i];  k++;  j=0;  c=0;  if (str[i]==ptrn[j])  {  j++;  c++;  }  }  }  data[k]='\0';  printf ("Received Data.... %s",data); } 

Parity

 bool getParity(unsigned int n) {  bool parity = 0;  while (n)  {  parity = !parity;  n = n & (n - 1);  }  return parity; } int main() {  unsigned int n = 7;  printf("Parity of no %d = %s", n,  (getParity(n)? "odd": "even"));  getchar();  return 0; } 

Crc

 #include<stdio.h> #include<conio.h> void main() { int i,f[20],n[50],div[50],j,temp,quotient[20],z[10]; printf("enter the number\n"); for(i=0;i<8;i++) { scanf("%d",&n[i]); } printf("enter the divisor\n"); for(i=0;i<4;i++) { scanf("%d",&div[i]); } for(i=8;i<12;i++) { n[i]=0; } for(i=0;i<8;i++) { temp=i; if(n[i]==1) { for (j=0;j<4;j++) { if (n[temp]==div[j]) {n[temp]=0; f[j]=0;} else {n[temp]=1; f[j]=1;} temp=temp+1; } quotient[i]=1; } else quotient[i]=0; } printf("\nthe quotient is \n"); for(i=0;i<8;i++) printf("%d",quotient[i]);  printf("\n and the remainder is \n "); for(j=0;j<4;j++) printf("%d",f[j]); getch(); } 

Ham

#include <math.h> #include <stdio.h> int input[32]; int code[32]; int ham_calc(int, int); void solve(int input[], int); int ham_calc(int position, int c_l) {  int count = 0, i, j;  i = position - 1;    while (i < c_l) {  for (j = i; j < i + position; j++) {  if (code[j] == 1)  count++;  }  i = i + 2 * position;  }  if (count % 2 == 0)  return 0;  else  return 1; } void solve(int input[], int n) {  int i, p_n = 0, c_l, j, k;   i = 0;    while (n > (int)pow(2, i) - (i + 1)) {  p_n++;  i++;  }  c_l = p_n + n;  j = k = 0;    for (i = 0; i < c_l; i++) {    if (i == ((int)pow(2, k) - 1)) {  code[i] = 0;  k++;  }  else {  code[i] = input[j];  j++;  }  }  for (i = 0; i < p_n; i++) {  int position = (int)pow(2, i);  int value = ham_calc(position...