How Byte loading/storing is implemented By the CPU?

I know that in 32bit machine, cpu read from memory 32bits at a time. since the registers in this case is 32bit in size too, I can understand how this works.

What I don’t understand is how the cpu implement load instructions of 1 byte. does it load the whole word where the single byte is located to the register, then perform some kind of “byte shifting”, or does the cpu can load a single byte, in this case when does the byte masking happen, is it until the byte got loaded in the register, or it happen when byte is send through the data bus ?

P.S. The cpu Im using is MIPS, the instructions Im talking about are: lb or lbu

7

It depends.

Some (CISC) CPUs have byte-wise loads that can address individual bytes so the byte of interest is the low-order 8-bits on the bus; the rest of the bits are masked off.

Many RISC CPUs will do word-load, barrel shift, while others will do word-load, bit shift and in the middle, are ones that do word-load, byte shift.

Some CPUs will do consecutive word-loads when a two-byte value spans a 32-bit boundary, shifting and masking the words together.

CPU families may do different implementations depending on the particular processor model. That explains why there is no description of the implementation; it’s a decision only the vendor cares about.

As for performance, you will just have to test it on the particular CPU and memory configurations you care about.

2

In many 32-bit machines without a memory cache, the memory will be divided into four 8-bit-wide sections, each of which will be connected to eight bits of the system bus and will have its own “enable” logic. If a processor executes a 16-bit store instruction, it will enable two of the eight sections and output the appropriate data on the wires that connect to them. The other two sections won’t be enabled, so their contents won’t be affected.

Note that while some machines split up both write and read operations the same way, it’s really only necessary that the memory subsystem allow “partial” writes. If the processor performs a 16-bit load, it will expect to receive data from the two 8-bit sections that contain the address in question, but won’t care if the other sections supply data as well. Each section has its own separate set of eight data pins, and the processor would ignore whatever data was placed on the unused sets.

Note also that in systems with memory caches, things get more complicated. Depending upon the caching architecture, a 16-bit store might cause the two memory banks that are being written to be set for “write” while those which aren’t would be set for “read”; all 32 bits of the cache would then be set to “write” (16 bits would grab data being stored by the CPU, while the other 16 would grab the other half of that same word, fetched from memory). Alternatively, it might only write 16 bits to the cache, but set flags indicating that the other 16 bits of that word are “unknown”. Despite this complexity, most CPU designers believe the semantic cleanliness of allowing 8- and 16-bit “store” instructions is worth the cost.

CPU can read single byte, but not only that one byte. In broader term, the byte might not be in memory yet, so a page needed to be loaded, update memory map and a store a chunk in cache (cache is in CPU too), then it can be loaded.

If you need less than a word, sign extension might be performed as mentioned in MIPS instruction set. The cpu loads the machine word (32bit) and depending on the instruction it’ll either perform sign extension or nullify the uninteresting bytes. So, it’s not simply “byte shifting”. Operations are done on register, so after it’s loaded.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

How Byte loading/storing is implemented By the CPU?

I know that in 32bit machine, cpu read from memory 32bits at a time. since the registers in this case is 32bit in size too, I can understand how this works.

What I don’t understand is how the cpu implement load instructions of 1 byte. does it load the whole word where the single byte is located to the register, then perform some kind of “byte shifting”, or does the cpu can load a single byte, in this case when does the byte masking happen, is it until the byte got loaded in the register, or it happen when byte is send through the data bus ?

P.S. The cpu Im using is MIPS, the instructions Im talking about are: lb or lbu

7

It depends.

Some (CISC) CPUs have byte-wise loads that can address individual bytes so the byte of interest is the low-order 8-bits on the bus; the rest of the bits are masked off.

Many RISC CPUs will do word-load, barrel shift, while others will do word-load, bit shift and in the middle, are ones that do word-load, byte shift.

Some CPUs will do consecutive word-loads when a two-byte value spans a 32-bit boundary, shifting and masking the words together.

CPU families may do different implementations depending on the particular processor model. That explains why there is no description of the implementation; it’s a decision only the vendor cares about.

As for performance, you will just have to test it on the particular CPU and memory configurations you care about.

2

In many 32-bit machines without a memory cache, the memory will be divided into four 8-bit-wide sections, each of which will be connected to eight bits of the system bus and will have its own “enable” logic. If a processor executes a 16-bit store instruction, it will enable two of the eight sections and output the appropriate data on the wires that connect to them. The other two sections won’t be enabled, so their contents won’t be affected.

Note that while some machines split up both write and read operations the same way, it’s really only necessary that the memory subsystem allow “partial” writes. If the processor performs a 16-bit load, it will expect to receive data from the two 8-bit sections that contain the address in question, but won’t care if the other sections supply data as well. Each section has its own separate set of eight data pins, and the processor would ignore whatever data was placed on the unused sets.

Note also that in systems with memory caches, things get more complicated. Depending upon the caching architecture, a 16-bit store might cause the two memory banks that are being written to be set for “write” while those which aren’t would be set for “read”; all 32 bits of the cache would then be set to “write” (16 bits would grab data being stored by the CPU, while the other 16 would grab the other half of that same word, fetched from memory). Alternatively, it might only write 16 bits to the cache, but set flags indicating that the other 16 bits of that word are “unknown”. Despite this complexity, most CPU designers believe the semantic cleanliness of allowing 8- and 16-bit “store” instructions is worth the cost.

CPU can read single byte, but not only that one byte. In broader term, the byte might not be in memory yet, so a page needed to be loaded, update memory map and a store a chunk in cache (cache is in CPU too), then it can be loaded.

If you need less than a word, sign extension might be performed as mentioned in MIPS instruction set. The cpu loads the machine word (32bit) and depending on the instruction it’ll either perform sign extension or nullify the uninteresting bytes. So, it’s not simply “byte shifting”. Operations are done on register, so after it’s loaded.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật