Big-endian, Little-endian – NEC Network Controller uPD98502 User Manual

Page 227

Advertising
background image

CHAPTER 3 SYSTEM CONTROLLER

Preliminary User’s Manual S15543EJ1V0UM

227

Figure 3-1. Bit and Byte Order of Endian Modes

B Y T E 0

B Y T E 1

B Y T E 2

B Y T E 3

B Y T E 4

B Y T E 5

B Y T E 6

B Y T E 7

4

0

M S B

L S B

31

0

MSB = Most Significant Byte

LSB = Least Significant Byte

Big-Endian

Big End

Little End

B Y T E 3

B Y T E 2

B Y T E 1

B Y T E 0

B Y T E 7

B Y T E 6

B Y T E 5

B Y T E 4

4

0

M S B

L S B

31

0

Little-Endian

Big End

Little End

If the access type matches the data item type, no swapping of data sub-items is necessary. Thus, when making

half-word accesses into a data array consisting of half-word data, no byte swapping takes place. In this case, data

item bit order is retained between the two endian modes. The code that sequentially accesses the half-word data

array would be identical, regardless of the endian mode of its V

R

4120A. The code would be endian-independent.

Figure 3-2. Half-word Data Array Example

A

H W 3

H a l f w o r d

Data Array

Big-Endian

Data extraction using sequential halfword access

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

H W 2

H W 1

H W 0

L S H W

M S H W

L S H W

M S H W

A

H W 3

Little-Endian

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

H W 2

H W 1

H W 0

L S H W

M S H W

L S H W

M S H W

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Order Retained

Data extraction using sequential halfword access

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Order Lost

Advertising