Presentation is loading. Please wait.

Presentation is loading. Please wait.

Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses.

Similar presentations


Presentation on theme: "Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses."— Presentation transcript:

1 Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses that are a multiple of four are called word aligned (start with 0,4,8,C). General Purpose Register 3 2 1 0 Not word aligned What looks like the binary address rightmost part for word aligned addresses ?

2 Endianness 1 2 3 4 5 6 7 8  A load word or store word instruction uses only one memory address.  The lowest address of the four bytes is used for the address of a block of four contiguous bytes.  How is a 32-bit pattern held in the four bytes of memory?  A choice has to be made about which byte of memory gets what part of the pattern.  There are two ways that computers commonly do this:  A load word or store word instruction uses only one memory address.  The lowest address of the four bytes is used for the address of a block of four contiguous bytes.  How is a 32-bit pattern held in the four bytes of memory?  A choice has to be made about which byte of memory gets what part of the pattern.  There are two ways that computers commonly do this: 1 23 45 67 8 General Purpose Register 3 2 1 0

3 Big Endian and Little Endian 1 2 3 4 5 6 7 8  Big Endian Byte Order: The most significant byte (the "big end") of the data is placed at the lowest addressed byte.  Little Endian Byte Order: The least significant byte (the "little end") of the data is placed at the lowest addressed byte.  Big Endian Byte Order: The most significant byte (the "big end") of the data is placed at the lowest addressed byte.  Little Endian Byte Order: The least significant byte (the "little end") of the data is placed at the lowest addressed byte. 1 23 45 67 8 General Purpose Register 3 2 1 0 Big Endian Order

4  Say that the 32-bit pattern 0x12345678 is at address 0x00400000.  The most significant byte is 0x12;  the least significant is 0x78.  Here are the two byte orders: Big, Little endian example Lowest Address The Most Significant byte This is memory, not registers

5  Within a byte, for all processors, bit 7 is the most significant bit.  So the big end byte looks the same for both byte orderings. Usually in printed material this bit is shown at the left, as in 00010010 Bit Order

6 Byte Order of MIPS and SPIM Intel 80x86: little-endian processor family Macintosh OS runs on computers based on big-endian processors. IBM z/Architecture – Big endian More and more architectures use Bi-Endian hardware Allow switchable endianness ARM versions 3 and above, PowerPC,, SPARC V9, MIPS PA-RISC, SuperH SH-4 and IA-64, Alpha The SPIM simulator uses the byte ordering of the computer it is running on.

7 Load Word 100011 01010 01000 0000 0000 0110 0000 lw $10 $8 0 0 6 0 opcode base dest offset lw $8, 0x60($10) The instruction immediately after a lw instruction should not use the register that is being loaded Which type of instruction is this ?

8 Store Word Instruction

9  A MIPS halfword is two bytes.  Halfword addresses must be halfword aligned.  Attempting to load a halfword from an unaligned address will cause a trap. Loading Halfwords

10 Address alignment for halfword When a halfword (2-bytes) is loaded or stored the memory address must be a multiple of 2. Addresses that are a multiple of 2 are called halfword aligned (start with 0,2,4,…). General Purpose Register 3 2 1 0 What looks like the binary address rightmost part for halfword aligned addresses ?

11 Storing Halfwords


Download ppt "Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses."

Similar presentations


Ads by Google