| OCR Text |
Show 31 The condition codes are modeled as long integers. This is counter-intuitive, since condition codes are only a single bit in the actual machine. However, C recognizes any nonzero integer value as a boolean "true" and only zero is evaluated as "false." Taking advantage of this idiosyncracy and declaring the modeled condition codes as type long leads to more efficient modeling of condition code setting in many cases. Specific examples of condition code setting are given in Section 3.2.6 which describes the details of instruction modeling. Two "scratch registers" tO and t1 are defined . These registers do not correspond directly to any of the MC68020 registers that are visible to the programmer. They are used to hold intermediate results necessary for the modeling of some instructions and condition codes. The types b, w, and correspond to the byte, word and longword MC68020 instruction modes. The in-struction mode determines whether the instruction is to act on 8 bit 16 bit or 32 bit operands. When one of the 8 data registers is used as an instruction operand, either the low order 8 bits, the low order 16 bits, or the entire 32 bits of the register will actually be used, according to the instruction mode. Data registers are modeled by the union type d_reg. Union types are used in C to hold objects of different types and sizes. The type returned from a reference to a union variable is determined by the member name. The member names in the union type d_reg are b, w, and I. These correspond, respectively, to the byte, word, and longword instruction modes of the MC68020. As an example, suppose that the hexidecimal value 12345678 has been stored in the number 1 data register. Given the definition of reg as a structure variable of type m _state, reg.d1 refers to the union variable corresponding this register. The reference reg.d1.b would return the hexidecimal value 78, reg.d1.w would return the hexdecimal value 5678, and reg.d1 .1 would return the hexidecimal value 12345678. The address union type is used in a slightly different fashion to model |