Homework 3 UCR EE/CS120B: Introduction to Embedded Systems Winter Quarter 2002, Prof. Frank Vahid Due Friday May 10 by 2:00 p.m. to Vahid's office, Surge 328 (put under door if door is closed) 1. Write assembly code, using the instruction set provided in ESD Fig 3.7, for the following: // assume x is M[3] // assume y is M[11] if (x == y) { x = 0; } else { y = 0; } 2. Repeat problem 1 using the 8051 instruction set. 3. Write 8051 assembly code that sends data to another device as follows. Initialize P1.1 to 0. Write the data R0 to P0. Set P1.1 to 1. Wait for at least 8 clock cycles. Set P1.1 to 0. Assume the 8051 is a "turbo" 8051 using 4 cycles per instruction, non-pipelined. 4. Design a 16-bit processor, having a Harvard architecture (separate program and data memory), able to support up to 32 instructions. It has 2K of data memory, 64K of program memory, 32 registers, and an accumulator. It supports the following instructions: * A = M(direct) * M(direct) = A * Rn = A * A = Rn * A = immediate * A = A + Rn * A = A - 1 (decrement) * Jump to PC+offset if A is 0 (offset up to +1024 or -1023) * Jump to PC+offset unconditionally (a) Define an instruction set using pneumonics. Also show the binary representation of the instruction. (i.e., do what was done in ESD Fig 3.7). Note that this is an accumulator-based machine -- the accumulator is involved in all memory transfers and arithmetic operations, and is implicit in those instructions. I.e., do NOT include a field for the accumulator. (b) Describe the processor as an FSMD, then create a datapath plus an FSM, and finally implement a control unit having a controller that uses a state-register plus ROM (show the ROM contents). (c) Comparing your processor to that of Fig 3.7, list the main advantage and disadvantage of an accumulator based machine (above) versus one without an accumulator (Fig 3.7) We recommend you do this problem using a word processor or other electronic capture tool, since drawing it out on paper may become cumbersome. 5. (a) Write an assembly program that uses your processor to compute the following. Assume w is M[1], x is M[2], y is M[3]. Assume you must update x and w in memory. while (w != 0) { x = x + y; w = w - 1; } (b) Translate the first three instructions of your program into binary.