CSC321
Microprocessor and
Assembly Language
Lecture-4
Muhammad Naveed Shaikh
Department of Electrical and Computer Engineering
COMSATS University Islamabad, Abbottabad Campus
[email protected]
CSC321-Microprocessors & Assembly Language
Memory Organization
• A bank of 1M byte locations, each having its own unique address
(0000016-FFFFF16).
• 220 = 1 MB = 1 Mega Bytes (for 8086 microprocessors)
• Memory lies outside the processor (External Memory )
• However, it is accessible to processor.
• Memory is used to store both
• Program (Code)
• Data
Muhammad Naveed Shaikh 2
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
• 8086 microprocessor can access 16 bits at once (per clock cycle)
• Data Bus is 16-bit wide
Memory
• However, each location can hold only 8-bits
Address(( Contents
• Thus, two locations are accessed simultaneously HEX) (HEX)
MPU
// //
16-bit Data Bus 072F0 1 BYTE
16-bit
072EF 1 BYTE
072EE 1 BYTE
Note: Recall the 8088 case and imagine the difference? // //
Muhammad Naveed Shaikh 3
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
• 8086 microprocessor can access 16 bits at once (per clock cycle)
• Data Bus is 16-bit wide
• However, each location can hold only 8-bits of information
• Thus, two locations are accessed simultaneously
• Two bytes information means 1 Word ( 2 Bytes)
• Little Endian
• Low address byte is least significant byte
• Higher address byte is most significant byte
Note: Recall the difference between Little Endian and Big Endian
Muhammad Naveed Shaikh 4
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Practice Example (LITTLE ENDIAN)
Memory
• Address location 07207H, 07208H
• Lower address is 07207H
Address (HEX) Content (Hex)
• Higher address is 07208H
• Least Significant byte is 4B H
07208 72
• Most Significant byte is 72 H
• 16-bit Word will be 724B H 07207 4B
What will be realization of same information based upon BIG ENDIAN?
Muhammad Naveed Shaikh 5
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
• Even address boundary
• Odd Address Boundary
Muhammad Naveed Shaikh 6
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Even address boundary
• If least significant bit of address is 0
• Word stored at an even-address boundary
• It corresponds to two consecutive bytes
• Least Significant Byte (LSB) is located at an even address
• Data is called Aligned Data
Remember Data Types can be Byte, word, double word (Pointer) on so on .
Muhammad Naveed Shaikh 7
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization Memory
Even address boundary
Example Address (HEX) Content (Hex)
The word 25A0 is stored at 0x00722 Address
00724 72
• LSB is A0 at even address (00722)
• MSB is 25 at odd address (00723) 00723 25
• Thus, 0x25A0 is an aligned word
00722 A0
Do you observe a miss-aligned word 0x7225? 00721 4B
Muhammad Naveed Shaikh 8
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Odd Address Boundary
• If least significant bit of address is 1
• Word stored at an odd-address boundary
• It corresponds to two consecutive bytes
• Least Significant Byte (LSB) is located at an odd address
• Data is called Miss-Aligned Data
Muhammad Naveed Shaikh 9
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization Memory
Odd address boundary
Example Address (HEX) Content (Hex)
The word 0x7225 is stored at 0x00723 Address
00724 72
• LSB is 25 hex at lower address (00723)
• MSB is 72 hex at Higher address (00724) 00723 25
• Thus, 0x7225 is a miss-aligned word.
00722 A0
Do you observe a miss-aligned word 0xA04B? 00721 4B
or a miss aligned Pointer 0x7225A04B?
Muhammad Naveed Shaikh 10
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Practice Problem
• Identify the given words as
• Aligned or Miss Aligned wrods
Muhammad Naveed Shaikh 11
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Double word
• 4 bytes of data or two words
• Example is pointer which is two word–address element
• to access either data or code in memory
• Double word is another data format
• that can be processed by 8086/ 8088 Microprocessor .
• It corresponds to 4 consecutive bytes stored in memory.
Muhammad Naveed Shaikh 12
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Memory Organization
Practice Problem
• Identify the given double-words as
• Aligned or Miss Aligned double wrods
Muhammad Naveed Shaikh 13
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Exercise Problems (1)
1. Find out the data word stored at 0xB0000?
• The LSB is stored at 0xB0000 and MSB is stored at B0001 (Little Endian Approach)
• Thus, data word is 00FF H. Address Data
2. Find out if this word is aligned or miss aligned? (Hex) (Hex)
B0006 44
• Since it is stored at even address boundary, it will be aligned word
B0005 33
3. Repeat the same exercise (1) and (2) B0004 22
for the words stored at
B0003 11
• 0xB0003
B0002 02
• 0xB0004 B0001 00
• 0xB0002 B0000 FF
Muhammad Naveed Shaikh 14
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Exercise Problems (2)
1. Find the value of double word starting at location B0003H?
• 44332211H
2. Is it aligned or miss aligned? Address Data
(Hex) (Hex)
• Miss aligned
B0006 44
B0005 33
3. Re do the exercise for the double word stored at B0004 22
1. 0xB0000 B0003 11
2. 0xB0003 B0002 02
B0001 00
B0000 FF
Muhammad Naveed Shaikh 15
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
References and Acknowledgements
• Information is mainly taken from the book:
The 8088 and 8086 Microprocessors Programing, Interfacing, Software,
Hardware and Applications by Walter A. Triebel and Avtar Singh
Muhammad Naveed Shaikh 16
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus
CSC321-Microprocessors & Assembly Language
Muhammad Naveed Shaikh 17
Department of Electrical and Computer Engineering, CUI, Abbottabad Campus