OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [binutils/] [ar/] [endian.c] - Blame information for rev 260

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 hellwig
/*
2
 * endian.c -- endianness conversions
3
 */
4
 
5
 
6
#include "endian.h"
7
 
8
 
9
unsigned int read4FromEco(unsigned char *p) {
10
  return (unsigned int) p[0] << 24 |
11
         (unsigned int) p[1] << 16 |
12
         (unsigned int) p[2] <<  8 |
13
         (unsigned int) p[3] <<  0;
14
}
15
 
16
 
17
void write4ToEco(unsigned char *p, unsigned int data) {
18
  p[0] = data >> 24;
19
  p[1] = data >> 16;
20
  p[2] = data >>  8;
21
  p[3] = data >>  0;
22
}
23
 
24
 
25
void conv4FromEcoToNative(unsigned char *p) {
26
  unsigned int data;
27
 
28
  data = read4FromEco(p);
29
  * (unsigned int *) p = data;
30
}
31
 
32
 
33
void conv4FromNativeToEco(unsigned char *p) {
34
  unsigned int data;
35
 
36
  data = * (unsigned int *) p;
37
  write4ToEco(p, data);
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.