본문 바로가기

전체 글168

3.9.2 Unions The syntax of a union declaration is identical to that for structures, but its semantics are very different A common method is to introduce an enumer- ated type defining the different possible choices for the union, and then create a structure containing a tag field and the union: Unions can also be used to access the bit patterns of different data types 3.9.3 Data Alignment The x86-64 hardware .. 2023. 4. 22.
3.8.3 Nested Arrays Data type row3_t is defined to be an array of three integers. 3.8.4 Fixed-Size Arrays This code contains a number of clever optimizations. It removes the integer index j and converts all array references to pointer dereferences. This involves (1) generating a pointer, which we have named Aptr, that points to successive elements in row i of A, (2) generating a pointer, which we have named Bptr, t.. 2023. 4. 19.
3.7.4 Local Storage on the Stack At times, however, local data must be stored in memory. Common cases of this include these: There are not enough registers to hold all of the local data. The address operator ‘&’ is applied to a local variable, and hence we must be able to generate an address for it. Some of the local variables are arrays or structures and hence must be accessed by array or structure references. We will discuss .. 2023. 4. 18.
3.7.1 The Run-Time Stack A key feature of the procedure-calling mechanism of C, and of most other languages, is that it can make use of the last-in, first-out memory management disci- pline provided by a stack data structure. the x86-64 stack grows toward lower addresses and the stack pointer %rsp points to the top element of the stack. When an x86-64 procedure requires storage beyond what it can hold in reg- isters, it.. 2023. 4. 18.
3.6.8 Switch Statements A switch statement provides a multiway branching capability based on the value of an integer index. They are particularly useful when dealing with tests where there can be a large number of possible outcomes. The advantage of using a jump table over a long sequence of if-else statements is that the time taken to perform the switch is independent of the number of switch cases. The array jt contai.. 2023. 4. 14.
3.6.7 Loops Do-While Loops While Loops The first translation method, which we refer to as jump to middle, performs the initial test by performing an unconditional jump to the test at the end of the loop. It can be expressed by the following template for translating from the general while loop form to goto cod The second translation method, which we refer to as guarded do, first trans- forms the code into a .. 2023. 4. 14.
3.6.5 Implementing Conditional Branches with Conditional Control The most general way to translate conditional expressions and statements from C into machine code is to use combinations of conditional and unconditional jumps 3.6.6 Implementing Conditional Branches with Conditional Moves Processors employ sophisticated branch pre- diction logic to try to guess whether or not each jump instruction will be followed. the code compiled using conditional moves requ.. 2023. 4. 13.
3.6 Control 3.6.1 Condition Codes the CPU maintains a set of single-bit condition code registers describing attributes of the most recent arithmetic or logical oper- ation. 3.6.2 Accessing the Condition Codes Rather than reading the condition codes directly, there are three common ways of using the condition codes: (1) we can set a single byte to 0 or 1 depending on some combination of the condition codes (.. 2023. 4. 10.
3.5 Arithmetic and Logical Operations the instruction class add consists of four addition instructions: addb, addw, addl, and addq, adding bytes, words, double words, and quad words, respectively 3.5.1 Load Effective Address The load effective address instruction leaq is actually a variant of the movq in- struction. It has the form of an instruction that reads from memory to a register, but it does not reference memory at all. 3.5.2.. 2023. 4. 10.
3.4.2 Data Movement Instructions Copying a value from one memory location to another requires two instructions—the first to load the source value into a register, and the second to write this register value to the des- tination. 3.4.3 Data Movement Example When the procedure begins execution, procedure parameters xp and y are stored in registers %rdi and %rsi, respectively For each entry in the table, show the two instructions .. 2023. 4. 8.
728x90