File: egcprog.c

package info (click to toggle)
lgrind 3.67-3
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 356 kB
  • sloc: ansic: 2,261; makefile: 125; asm: 75; sh: 39
file content (34 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* endian.c
 * Demonstrates endian ordering
 */

#include <stdio.h>

void main( void )
{
	short   Data_16; 
	long    Data_32;
	char far *p;

	Data_16 = 0x1234;
	Data_32 = 0x56789abc;

	p = (char far *)&Data_16;
	printf("16-bit quantity, data=%04x\n", Data_16);
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
	p++ ;
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
	p++ ;


	p = (char far *)&Data_32;
	printf("32-bit quantity, data=%08lx\n", Data_32);
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
	p++ ;
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
	p++ ;
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);
	p++ ;
	printf("address %Fp = %02x\n", p, (int)(*p) & 0xff);

}