UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

Similar documents
Exam I Review February 2017

1. Memory Mapped Systems 2. Adding Unsigned Numbers

What is an Addressing Mode?

Programming the Motorola MC68HC11 Microcontroller

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access

Sample Problem Set #1

The Motorola 68HC11 Instruc5on Set

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

0b) [2] Can you name 2 people form technical support services (stockroom)?

Mark II Aiken Relay Calculator

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #1 ECE 3610 MICROPROCESSING SYSTEMS

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

CHAPTER 8. Solutions for Exercises

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam.

Exam 2 E2-1 Fall Name: Exam 2

CMPEN 472 Sample EXAM II

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

EB301. Motorola Semiconductor Engineering Bulletin. Programming EEPROM on the MC68HC811E2 during Program Execution. Freescale Semiconductor, I

Cross Assembly and Program Development

538 Lecture Notes Week 3

Using the stack and the stack pointer

Exam 1 Feb. 23, 25, 27?

Lecture 6 Assembly Programming: Branch & Iteration

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

Introduction to Microcontrollers II

Outline. 2.8 Stack. 2.9 Subroutines

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Coe538 Final Study Guide 2016 (Questions & Answers)

ECE 372 Microcontroller Design Basic Assembly Programming. ECE 372 Microcontroller Design Basic Assembly Programming

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Introduction to Microcontrollers II

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

AN Kbyte Addressing with the M68HC11. Overview

HC11 Instruction Set

ECE 3610 MICROPROCESSING SYSTEMS

It translates (converts) assembly language to machine code.

EE 308 Spring The HCS12 has 6 addressing modes

MC68705U3 Bootstrap ROM

A Simple MC9S12 Program

instruction 1 Fri Oct 13 13:05:

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

538 Lecture Notes Week 2

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3

CS/ECE 5780/6780: Embedded System Design

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets

SECTION 6 CENTRAL PROCESSING UNIT

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016

Exam 2 E2-1 Fall Name: Exam 2

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE

Lecture 9 Subroutines

EE 3170 Microcontroller Applications

CE-320 Microcomputers I Winter 2010 LAB 1: MINIIDE GROUP #: NAME: PARTNER: Lab 1 Page 1

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

CPU12 REFERENCE MANUAL

Lecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015

ME 6405 Introduction to Mechatronics

m 1 se 7 m 23 Introduction to Embedded Microcomputer Systems Lecture 16.1 Recap Finite State Machines Pointer implementation

ECE 3610 MICROPROCESSING SYSTEMS AN ENCRYPTED ASCII CODE DECODER

ECE 367 -Experiment #1 Fall 2012

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions

538 Lecture Notes Week 1

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Timing Generation and Measurements

Ryerson Polytechnic University Department of Electrical Engineering COE328 Digital Systems. (2 Weeks) FORMAL REPORT - 30 Marks Due Date: Week 13

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

ECE/CS 5780/6780: Embedded System Design

Disassembly of an HC12 Program It is sometimes useful to be able to convert HC12 op codes into mnemonics. For example, consider the hex code:

Computers and Microprocessors

; export symbols XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for assembly entry point

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

Homework 12 Solutions

EE319 K Lecture 7. Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines. University of Texas ECE

MIGRATING TO THE 68HC12 IN C

Processor Design. ELEC 418 Advanced Digital Systems Dr. Ron Hayne

AN-HK-32. In-Circuit Programming of FLASH Memory in the MC68HC908GP32. nc... Freescale Semiconductor, I. PART 1 Introduction

ECE/CE 3720: Embedded System Design

ECE/CS 3720: Embedded System Design (ECE 6960/2 and CS 6968)

Module 1-G. Marcos and Structured Programming

Harry H. Porter, 2006

Comparison of C and Assembly How to compile a C program using CodeWarrior

Introduction to Microcontrollers III

ECE 3120 Lab 1 Code Entry, Assembly, and Execution

Administrivia. ECE/CS 5780/6780: Embedded System Design. Assembly Language Syntax. Assembly Language Development Process

Motorola HC11. Fun with Microcontrollers and Embedded Systems

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

MC68705P3 Bootstrap ROM

Transcription:

ECE 3610 Test 2 Solution 1 of 7 PRINT LAST NAME: STUDENT NUMBER PRINT FIRST NAME: UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING DATE: Feb. 28, 11; TIME: 6:00-8:00 P.M. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS This is an open book test. You may bring the course book, and other notes. However, all material must be bound in one container; loose leaf is not allowed. Electronic communications devices are strictly prohibited. Calculators are not allowed. Answer all questions in the space provided.

ECE 3610 Test 2 Solution 2 of 7 1. The following program is a multiple precision unsigned addition program, much like the one you worked on in the lab. The program code and data are to be stored in the inclusive range $4000 to $4FFF. There are no other memory chips available. Analyze this program, and answer the following questions based on the given program: [1.1] Assemble the source code. Place the machine code in the Machine Code column, and fill out the Address column. In the Mode column, identify the addressing mode used by the instruction. Place the machine code starting at memory location 4100 (as indicated). [1.2] How many locations are available to store the first number? 7E-00 + 1 = 7F = 127 [1.3] How many locations are available to store the second number? FB-7F + 1 = 7D = 125 [1.4] How many locations are available to store the result? FE-FC + 1 = 03 = 3 [1.5] What is the maximum precision this program can process? 2 [1.6] What is the purpose of location $40FF? Stores the precision Line Address Machine Code Assembly Language Mode 4000 Num1 MSB 407E 407F Num1 LSB Num2 MSB 40FB 40FC 40FD 40FE 40FF Num2 MSB Result MSB Result LSB precision 1 4100 0C 2 3 4101 F6 40 FF LDAB $40FF EXT 4 4104 CE 40 00 LDX #$4000 IMM 5 6 4107 A6 7E NEXT LDAA $7E,X IND,X 7 4109 A9 FB ADCA $FB,X IND,X 8 410B A7 FE STAA $FE,X IND,X 9 10 410D 09 DEX INH 11 410E 5A DECB INH 12 410F 26 F6 BNE NEXT REL 13 4111 89 00 ADCA #$00 IMM 14 4113 A7 FE STAA $FE,X IND,X 15 4115 FE HERE BRA HERE REL

ECE 3610 Test 2 Solution 3 of 7 [1.7] The objective of this next set of questions is to modify the above program to perform multiple precision signed addition. Use the following steps: [1.7.1] Perform the following addition of SIGNED numbers. Use three bytes to represent the result of each addition. 7FFE 7FFF FFFE 7FFF 8000 0001 FFFF FFFF 0001 FFFF 00 7FFF 00 7FFE FFFFFD 00 8000 FF 7FFF

ECE 3610 Test 2 Solution 4 of 7 [1.7.2] Create a flow chart, which uses method 1, as discussed in class, and repeated here: If overflow is false, then sign extend the result. In more words, prepend $00 to the n-byte result if the n-byte result is positive; and prepend $FF to the n-byte result if the n-byte result is negative. If overflow is true, and the MSBit of the n-byte result is 1, then prepend $00 to the n-byte result. If overflow is true, and the MSBit of the n-byte result is 0, then prepend $FF to the n-byte result. Start A 00 0 0 1 1 N V N 1 A FF 0 (FF,X) A End [1.7.3] Translate your flow chart to assembly language. Start your program at line 13. You may assume that instructions from lines 8-12, inclusive, do not affect the V-bits of the CCR. Line Assembly Language 1 CLC 2 3 LDAB $40FF 4 LDX #$4000 5 6 NEXT LDAA $7E,X 7 ADCA $FC,X 8 STAA $FF,X 9 10 DEX 11 DECB 12 BNE NEXT 13 START BVS V=1 V=0 BMI N=1 N=0 CLRA BRA WRITE N=1 LDAA #$FF BRA WRITE V=1 BMI N=1 N=0 LDAA #$FF BRA WRITE N=1 CLRA WRITE STAA $FF,X Line Assembly Language (Continued) DONE BRA DONE Note: I assumed that lines 8-12, inclusive, do not affect the N-bit of the CCR, as well.

ECE 3610 Test 2 Solution 5 of 7 2 Answer the following questions regarding the program given below. The program is to be stored in memory at location $4100. [2.1] In the space provided, list the contents of the stack and the value of the stack pointer after line 7 has run twice. [2.2] How many times does the Again loop run? 7E times = 126 times. [2.3] How many times does the s_main loop run? If your answer is not infinite times, then explain your answer. Once. The code replaces LDS #$4102 with JMP $4100, and ths make the program continually execute th new instruction JMP $4100. LINE REGISTER CONTENTS STACK ADDRESS 1 s_main LDS #$4102 2 LDAA #$7E 3 LDX #$4100 4 Again PSHX 5 PSHA 6 DECA 7 BNE Again 8 PULX 9 PULA 10 NOP 11...... 12 BRA s_main 40F7 7B 40F8 41 40F9 00 40FA 7C 40FB 41 40FC 00 40FD 7D 40FE 41 40FF 00 4100 7E 4101 41 4102 00 CONTENTS

ECE 3610 Test 2 Solution 6 of 7 3 Complete the timing diagram for instruction PULA. You might not need four clock cycles. 1 1.1 1.2 2.1 2.2 3.1 3.2 4.1 4.2 2 1.3 1.4 2.3 2.4 3.3 3.4 4.3 4.4 -OP_1 1.1 MAR PC -OP_3 3.1 MAR SP 1.2 PC PC + 1 3.2 1.3 DBUS = Mem(ABUS), MUX0 DBUS_MDR, MDR_WRITE, MUX1_OCR 1.4 OCR DBUS 3.3 DBUS = Mem(ABUS), MUX0 DBUS_MDR, MDR_WRITE, MUX1_MUX2&ALU, MUX2_MUX1_ACCA, ALU_PASS_B 3.4 CCR_LOAD, ACCA_LOAD -OP_2 2.1 2.2 SP SP+ 1 2.3 -OP_4 4.1 4.2 2.4 4.3 4.4 t

ECE 3610 Test 2 Solution 7 of 7 4 Write Verilog code and use the DE2 board to implement a digital data separator. A clock running at 50 MHz is available at pin called CLK_50. Every positive edge of CLK_50, 9-bit data will be delivered to the FPGA at pins called DD[8:0]. Your task is to separate the data on DD[7:0] based on the control input DD[8]. If DD[8] is a 1, then the byte on DD[7:0] shall be written to memory 1; If DD[8] is a 0, then the byte on DD[7:0] shall be written to memory 2; If DD[8] is a z, then the byte on DD[7:0] shall be dropped, i.e., ignored. The memories should have size 256x8. If a memory becomes full, then the first location should be reused, overwriting the previous contents. In other words, implement a circular memory. CLK_50 DD[8] Separator Memory 1 DD[7] DD[0] New data is presented each +ve edge of CLK_50. Memory 2 module TopLevelDesignEntity (input [8:0] DD, input CLK_50); reg [7:0] ram1 [255:0]; //My memory 1 declaration reg [7:0] ram2 [255:0]; //My memory 2 declaration reg [7:0] ram1address, ram2address; // memory addresses always @ (posedge CLK_50) case (DD[8]) 1: begin ram1[ram1address] <= DD[7:0]; ram1address <= ram1address + 1; end 0: begin ram2[ram2address] <= DD[7:0]; ram2address <= ram2address + 1; end endcase endmodule