hw8s - ENGRD2300: Introduction to Digital Logic Fall 2008...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ENGRD2300: Introduction to Digital Logic Fall 2008 Homework 8 Solutions Problem 1. Ezra Cornell is rumored to have written the following assembly language program for your Lab 7 microprocessor. SUB R0,R0,R0 LB R1,0(R0) LB R2,1(R0) SUB R3,R1,R2 BLTZ R3, L1 SB R1,2(R0) BEQ R0,R0,L2 L1: SB R2,2(R0) L2: HALT a) Translate this program into machine language (i.e., 16-bit instructions to be loaded into the Instruction RAM.) 1111 000 000 000 001 SUB R0,R0,R0 0010 000 001 000000 LB R1,0(R0) 0010 000 010 000001 LB R2,1(R0) 1111 001 010 011 001 SUB R3,R1,R2 1011 011 000 000010 BLTZ R3, L1 0100 000 001 000010 SB R1,2(R0) 1000 000 000 000001 BEQ R0,R0,L2 0100 000 010 000010 SB R2,2(R0) 0000 000 000 000 001 HALT For clarity, the bits in the machine language instructions are grouped into 4-3-3-3-3 bits or 4-3-3-6 bits depending on whether they are R-format or I-format instructions. The spaces need not be included in the answer. b) For each machine instruction, determine 31-bit control word for that instruction. (I.e., for each instruction, what are the 31 bits output by the decoder?) Instruction F OP FUNCT DR SA SB IMM MB FS MD RW MW BS OFF SUB R0,R0,R0 R 1111 001 000 000 000 -- 0 SUB 0 1 0 000 -- LB R1,0(R0) I 0010 001 000 -- 000000 1 ADD 1 1 0 000 -- LB R2,1(R0) I 0010 010 000 -- 000001 1 ADD 1 1 0 000 -- SUB R3,R1,R2 R 1111 001 011 001 010 -- 0 SUB 0 1 0 000 -- BLTZ R3, 14 I 1011 -- 011 -- 000000 1 SUB - 0 0 100 000010 SB R1,2(R0) I 0100 -- 000 001 000010 1 ADD - 0 1 000 -- BEQ R0,R0,16 I 1000 -- 000 000 -- 0 SUB - 0 0 010 000001 SB R2,2(R0) I 0100 -- 000 010 000010 1 ADD - 0 1 000 -- HALT R 0000 001 -- -- -- -- -- -- - 0 0 000 -- 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENGRD2300: Introduction to Digital Logic Fall 2008 c) Assuming that the data RAM contains the values 3,6 and 9 at addresses 0, 1, and 2, trace the execution of this program. What is the final state of the data RAM after execution? The data RAM will contain the values 3,6, and 6 at address 0,1, and 2. d) Explain what this program does.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/09/2009 for the course ENGRD 2300 taught by Professor Albonesi/long during the Fall '07 term at Cornell University (Engineering School).

Page1 / 8

hw8s - ENGRD2300: Introduction to Digital Logic Fall 2008...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online