Data Format In Registers; Data Formats In Memory - Hitachi SH7750 Programming Manual

High-performance risc engine superh (sh) 32-bit risc mcu/mpu series
Hide thumbs Also See for SH7750:
Table of Contents

Advertisement

2.4

Data Format in Registers

Register operands are always longwords (32 bits). When a memory operand is only a byte (8 bits)
or a word (16 bits), it is sign-extended into a longword when loaded into a register.
2.5

Data Formats in Memory

Memory data formats are classified into bytes, words, and longwords. Memory can be accessed in
8-bit byte, 16-bit word, or 32-bit longword form. A memory operand less than 32 bits in length is
sign-extended before being loaded into a register.
A word operand must be accessed starting from a word boundary (even address of a 2-byte unit:
address 2n), and a longword operand starting from a longword boundary (even address of a 4-byte
unit: address 4n). An address error will result if this rule is not observed. A byte operand can be
accessed from any address.
Big endian or little endian byte order can be selected for the data format. The endian should be set
with the MD5 external pin in a power-on reset. Big endian is selected when the MD5 pin is low,
and little endian when high. The endian cannot be changed dynamically. Bit positions are
numbered left to right from most-significant to least-significant. Thus, in a 32-bit longword, the
leftmost bit, bit 31, is the most significant bit and the rightmost bit, bit 0, is the least significant
bit.
The data format in memory is shown in figure 2.5. In little endian mode, data written as byte-size
(8 bits) should be read as byte size, and data written as word-size (16 bits) should be read as word
size.
A
31
7
Address A
Byte 0
15
Address A + 4
Word 0
31
Address A + 8
31
A + 1
A + 2
A + 3
23
15
7
0 7
0 7
0 7
Byte 1 Byte 2 Byte 3
0 15
Word 1
Longword
Big endian
Figure 2.5 Data Formats In Memory
Longword
A + 11
A + 10 A + 9
0
31
23
0
7
0 7
Byte 3
Byte 2 Byte 1 Byte 0
0
15
Word 1
0
31
Longword
Little endian
0
A + 8
15
7
0
0 7
0 7
0
Address A + 8
0
15
0
Address A + 4
Word 0
0
Address A
Rev. 2.0, 03/98, page 21 of 396

Advertisement

Table of Contents
loading

Table of Contents