What is a misaligned operand? Why are misaligned operands such a problem in programming?

What will be an ideal response?


If all instructions and data values were the same length and equal to the length of a computer word, the concept of a misaligned operand would not exist. However, in the real world, some data operands are shorter than a computer word. For example, computers with 32?bit wordlengths can operate with 8?bit or 16?bit data values.

A misaligned operand exists if the address of the operand is not on a boundary that is an integer multiple of the operand size. Suppose memory is byte addressed. A byte operand can be on any byte boundary and cannot be misaligned. Now consider a 16?bit value. That takes two bytes. Consequently a 16?bit value is aligned at addresses 0, 2, 4, 8, … ; that is all even addresses. A 16?bit value at an odd address is misaligned because it is split between two aligned words, e.g., a 16?bit value at address 7 would have one byte at address 7 and one at address 8, thereby occupying two word slots at byte addresses 6, 7 and 8, 9. Similarly, a 32?bit word would be aligned at addresses 0, 4, 8, ….

Conceptually, a misaligned word is not a problem; that is, you just read data from memory. Who cares where it comes from? In practice, misalignment is a problem. At worse, the computer may crash (i.e., abort the program because a misaligned operation is illegal). At best, it slows the computer because what should be a single memory access becomes two memory accesses. If a 32?bit word were misaligned at location 9, the word at location 8 (bytes 8, 9, 10, 11) would be read. The desired word is at address 9, 10, 11, 12. Consequently, the words at 12, 13, 14 would have to be read and the byte at 12 extracted and appended to the three bytes already read.

Computer Science & Information Technology

You might also like to view...

The aim of ____ is to maintain an optimum and secure relationship between each of the company's business processes and their respective information security functions.

A. formal governance B. informal governance C. formal auditing D. formal planning

Computer Science & Information Technology

Answer the following statements true (T) or false (F)

1. Once a field has been specified as a primary key, Visual Basic will not allow that field to contain an empty entry for any record. 2. LINQ can be used in Visual Basic to sort records. 3. A LINQ clause beginning with Join and ending with a phrase of the form On foreign key of tblA Equals primary key of tblB causes two tables to be joined. 4. The Move next button of a navigator toolbar is never disabled. 5. When a navigation toolbar is used with a table from a database, the value of BindingSource1.Position is the index of the current record.

Computer Science & Information Technology

A(n) ________ typeface allocates space for each character based on the width of the character

Fill in the blank(s) with correct word

Computer Science & Information Technology

A font theme consists of two fonts for ________

A) title and text B) title and cells C) heading and text D) numbers and text

Computer Science & Information Technology