HP85 GPIB Disk Emulator  1.0
HP85GPIBDiskEmulator
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vector.c
Go to the documentation of this file.
1 
11 #include "user_config.h"
12 
13 #include "vector.h"
14 
22 void V2B_MSB(uint8_t *B, int index, int size, uint32_t val)
23 {
24  int i;
25  for(i=size-1;i>=0;--i)
26  {
27  B[index+i] = val & 0xff;
28  val >>= 8;
29  }
30 }
31 
32 
33 // =============================================
41 void V2B_LSB(uint8_t *B, int index, int size, uint32_t val)
42 {
43  int i;
44  for(i=0;i<size;++i)
45  {
46  B[index+i] = val & 0xff;
47  val >>= 8;
48  }
49 }
50 
51 
58 uint32_t B2V_MSB(uint8_t *B, int index, int size)
59 {
60  int i;
61  uint32_t val = 0;
62 
63  for(i=0;i<size;++i)
64  {
65  val <<= 8;
66  val |= (uint8_t) (B[i+index] & 0xff);
67  }
68  return(val);
69 }
70 
71 
78 uint32_t B2V_LSB(uint8_t *B, int index, int size)
79 {
80  int i;
81  uint32_t val = 0;
82 
83  for(i=size-1;i>=0;--i)
84  {
85  val <<= 8;
86  val |= (uint8_t) (B[i+index] & 0xff);
87  }
88  return(val);
89 }
90 
91 
98 void B2S(uint8_t *B, int index, uint8_t *name, int size)
99 {
100  int i;
101  for(i=0;i<size;++i)
102  name[i] = B[index+i];
103  name[i] = 0;
104 }
B2V_LSB
uint32_t B2V_LSB(uint8_t *B, int index, int size)
Convert a byte array into a value bytes are LSB ... MSB order.
Definition: vector.c:78
vector.h
B2V_MSB
uint32_t B2V_MSB(uint8_t *B, int index, int size)
Convert a byte array into a value bytes are MSB ... LSB order.
Definition: vector.c:58
B2S
void B2S(uint8_t *B, int index, uint8_t *name, int size)
Create a string from data that has no EOS but known size.
Definition: vector.c:98
V2B_MSB
void V2B_MSB(uint8_t *B, int index, int size, uint32_t val)
Convert Value into byte array bytes are MSB ... LSB order.
Definition: vector.c:22
V2B_LSB
void V2B_LSB(uint8_t *B, int index, int size, uint32_t val)
Convert Value into byte array bytes are LSB ... MSB order.
Definition: vector.c:41