CS270 Colorado State University ========= PA3 ========= ---------------- LC3state Parts of the structure ControlState cs; Word field for each of the registers. BIT enumerated type for N, Z, and P condition codes. memory array to hold simulated memory locations. Represents the full state of the LC3 machine. Passing around a pointer to LC3state instead of the whole structure. Recall the three possible things that can be stored in memory. Any variable in C declared with a star/asterix after the type is a pointer type and is meant to hold a memory address. Why passing around pointer to LC3state? Pointers to structures LC3state_equal Two LC3states are equal if all of their fields are equal. alu ALU_ADD ALU_AND ALU_XOR decode LC3state_write_reg LC3state_read_mem [ m->MDR = m->memory ========= LC3 ========= ---------------- Addressing Modes Addressing mode indicates where the operand is located. 1. Register 2. Immediate 3. Memory The effective address is encoded in instruction (direct or PC-relative). Pointer to effective address is encoded in instruction (indirect) Pointer to the effective address is in a register. (relative, or base+offset) ---------------- Datapaths ADD R2, R5, #-8 ADD R1, R2, R3 LDR R2, R3, x1D ------------------------ mstrout@cs.colostate.edu, 10/1/08