Advertisement
CosminVarlan

4. Arduino = little-Endian

Dec 16th, 2021
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   vom stoca in variabila val care este pe 16 biti, fara semn
  3.   valoarea hexazecimala 0x1234. Deoarece Arduino este little-endian
  4.   va stoca cel ma putin semnificativ octet la adresa mai mica in
  5.   timp ce byteul mai semnificativ va fi stocat la adresa mai mare.
  6.  
  7.   Acest cod demonstreaza ca Arduino = little-endian
  8.    
  9.  
  10.   " A big-endian system stores the most significant
  11.   byte of a word at the smallest memory address and
  12.   the least significant byte at the largest. A little-endian
  13.   system, in contrast, stores the least-significant byte
  14.   at the smallest address."  
  15.  
  16.         Sursa: https://en.wikipedia.org/wiki/Endianness
  17.  
  18. */
  19.  
  20.  
  21. void setup()
  22. {
  23.   Serial.begin(9600);
  24.   uint16_t val = 0x1234;
  25.   uint8_t* p = (uint8_t *)&val;
  26.   Serial.println(*p, HEX);
  27.   p++;
  28.   Serial.println(*p, HEX);
  29. }
  30.  
  31. void loop()
  32. {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement