CMPEN 472 Sample EXAM II

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

Exam I Review February 2017

Using the stack and the stack pointer

Exam 2 E2-1 Fall Name: Exam 2

Exam 1 Feb. 23, 25, 27?

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

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Lecture 20: Interrupt Devices

ECE 3120 Computer Systems Arithmetic Programming

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

Coe538 Final Study Guide 2016 (Questions & Answers)

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

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

Sample Problem Set #1

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

ECE 367 -Experiment #1 Fall 2012

Chapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

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

Programming the Motorola MC68HC11 Microcontroller

Lab 7: Asynchronous Serial I/O

Cross Assembly and Program Development

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

Exam 2 E2-1 Fall Name: Exam 2

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

Homework 3 Aid Understanding Homework 2/3 Program

It translates (converts) assembly language to machine code.

Programming Book for 6809 Microprocessor Kit

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

538 Lecture Notes Week 5

538 Lecture Notes Week 5

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

Lecture 9 Subroutines

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.

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

538 Lecture Notes Week 3

ME 6405 Introduction to Mechatronics

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

Go Gators! Relax! May the Schwartz be with you!

HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks!

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

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

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

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

HC11 Instruction Set

Mark II Aiken Relay Calculator

CET335 Microprocessor Interfacing Lab 5: LCD Interface (Bus Attached Peripheral)

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

Outline. 2.8 Stack. 2.9 Subroutines

University of Florida EEL 4744 Fall 1998 Dr. Eric M. Schwartz

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

AN Kbyte Addressing with the M68HC11. Overview

EE 308 Spring The HCS12 has 6 addressing modes

1. Memory Mapped Systems 2. Adding Unsigned Numbers

CS/ECE 5780/6780: Embedded System Design

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

Introduction to Microcontrollers II

ECE 3610 MICROPROCESSING SYSTEMS AN ENCRYPTED ASCII CODE DECODER

Immediate vs. Extended mode: Immediate values are marked with a # symbol. They also are different instructions when assembled.

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces

Introduction to Microcontrollers II

Lecture 10 I/O and Interrupts

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const

Introduction to Microcontrollers

The Motorola 68HC11 Instruc5on Set

Total: EEL 3701 Digital Logic & Computer Systems Final Exam Fall Semester 2007 COVER SHEET: Re-Grade Information: 1 (10) 2 (10) 3 (10) 4 (14) 5 (14)

Module 1-D. Control Structure Applications. Tim Rogers 2017 [1.D]-1

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

ECE 331: PC Lab 3 Stack and Subroutines

ECE3120: Computer Systems Hardware & Software Development Tools

Lecture 11: Advanced Arithmetic Instructions

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

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

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

Lecture 5 Assembly Programming: Arithmetic

Module 1-G. Marcos and Structured Programming

538 Lecture Notes Week 2

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

Introduction to the 9S12 Microcontroller

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE

Introduction to Embedded Systems. Some Nagging

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Introduction to Microcontrollers III

An ability to program a microcontroller to perform various tasks

MC68HC12 Parallel I/O

Quick Guide to Using Code Warrior

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

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.

Timing Generation and Measurements

Chapter 2 HCS12 Assembly Language

Getting Started with the HCS12 IDE

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

Input and Output Ports. How do you get data into a computer from the outside?

ECET Chapter 2, Part 3 of 3

ECE 3610 MICROPROCESSING SYSTEMS

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

ECE/CE 3720: Embedded System Design

Motorola HC11. Fun with Microcontrollers and Embedded Systems

BRANCH IF REGISTER IS HIGHER/GREATHER/ THAN OPERAND e.g. CMPA #$D0

Transcription:

CMPEN 472 Sample EXAM II Name: Student ID number (last 4 digit): Please write your name on every page. Write your solutions clearly. You may use backside of each page for scratch but the solutions must be shown on the designated place near (or below) each problem. For any program you are asked to write, write it as short as possible. In most cases, a shorter program runs quicker and saves memory space; hence, it is more efficient. Any subroutine you write, make it transparent to its caller. Please ask if any of the problems (and assumptions) is not clear. PENALTY applies to long subroutines, its length greater than the suggested length. 1. (15pt) Write a short subroutine to convert the two digit decimal number input from a keyboard to a binary number and place the result in the accumulator A. Assume that the keyboard inputs are received through MC9S12C128 s SCI port and they are stored in the memory locations labeled TEN and ONE. The key-board inputs are always two digit decimal number from 00 to 99. Design your subroutine as short as possible. Your subroutine must be transparent to its caller. D EAMPLE: A $5B B X Y TEN ONE $39 $31 91 = $5B = %01011011

2. (15pt) Write a short subroutine to convert a number from the accumulator A for terminal display. The subroutine generates two byte ASCII characters for terminal display of the accumulator A content in HEX. Store the results in the memory locations labeled MSB and LSB. Design your subroutine as short as possible. Your subroutine must be transparent to its caller. D EXAMPLE A B $5B X Y MSB LSB $35 $42 5 B 91 = $5B = %01011011

3. (15pt) Three unsigned binary numbers are received from the port A of the MC9S12C128 and they are stored on the stack. The three numbers are needed to be sorted in ascending order. Given the main program below, write a short subroutine which will SORT the three numbers stored on the stack. MAIN: LDAA PSHA LDAA PSHA PORTA PORTA LDAA PSHA JSR PULA STAA PULA STAA PULA STAA PORTA SORT MIN mid MAX

4. (15pt) Show the memory contents of the stack after the Real Time Interrupt (RTI) has been occurred to HCS12. The RTI occurred during the execution of instruction at line 26. The interrupt handling has been initiated and the first instruction SWI has been executed. Show the memory contents of the stack during the beginning of the execution of the first instruction from the interrupt service routine at ISRSWI. 01 0037 CRGFLG EQU $0037 02 0038 CRGINT EQU $0038 03 003b RTICTL EQU $003B 04 3ff0 ORG $3FF0 05 3ff0 39 25 DC.W ISRRTI 06 3ff6 ORG $3FF6 07 3ff6 39 28 DC.W ISRSWI 08 09 3900 ORG $3900 10 3900 StackST 11 3900 cf 39 00 LDS #StackST 12 3903 4c 3b 39 bset RTICTL,%00111001 13 3906 4c 38 80 bset CRGINT,%10000000 14 3909 4c 37 80 bset CRGFLG,%10000000 15 390c cc ff 00 LDD #$FF00 16 390f b7 02 TAP 17 3911 ce f0 f0 LDX #$F0F0 18 3914 cd ab cd LDY #$ABCD 19 3917 10 ef cli 20 3919 16 39 20 JSR SUB1 21 391c a7 nop 22 391d a7 mloop nop 23 391e 20 fd bra mloop 24 25 3920 a7 SUB1: NOP 26 3921 a7 LOOP1: NOP 27 3922 20 fd BRA LOOP1 28 3924 3d RTS 29 30 3925 3f ISRRTI: SWI 31 3926 a7 NOP 32 *** 33 *** 34 3927 0b RTIEND: RTI 35 36 3928 a7 ISRSWI: NOP 37 *** 38 *** 39 3929 0b SWIEND: RTI 40 END $38F0 $38F8 $3900

5. (15pt) We want to generate square wave on bit 4 of the port B on the MC9S12C128 chip. The continuous square wave has the period of 0.5sec: 5V output for 0.25sec and 0V output for 0.25sec assuming 24MHz bus clock, 4MHz external resonator (same setting as the homework on CSM-12C128 board. Write the main program and the interrupt service routine for this task using the Real Time Interrupt feature. Use the memory locations starting at $3100 for your program and at $3000 for the data, if needed. Design your main.asm source file as a stand-alone program (same as the homework programs) including any necessary initialization.

6. (15pt) Write a short subroutine to add two 24 bit numbers in memory locations labeled N1 and N2. Store the result in N1. Design your subroutine as short as possible. Your subroutine must be transparent to its caller. N1: msb lsb N2: msb lsb

7. (15pt) Write a short subroutine 'putchar' to correctly send a byte data through MC9S12C128's SCI port. Use accumulator A for the data passing: A = character to send through the SCI port.

8. (15pt) Write a short subroutine 'printmsg' to print a line of text message on a Hyper Terminal connected to MC9S12C128's SCI port. Assume the message text always ends with ASCII null character 0 and the register X points to the first character to print. Also assume that your 'putchar' subroutine above is correctly working.

9. (15pt) When executing the MC9S12C128 program shown below, show the HyperTerminal window display. ORG $3100 LDS #$3100 LDAA #$65 LDAB #$43 LDX #256 IDIV TBA JSR putchar XGDX TBA JSR putchar Loop: BRA Loop

10. (15pt) Write a program to accept a user input up to 20 characters ending with an enter key and display the user input in the middle of the HyperTerminal window (eg. 5,15 position) with blue color. Write the main program and the subroutine. Use the memory locations starting at $3100 for your program and at $3000 for the data, if needed. Design your main.asm source file as a stand-alone program (same as the homework programs) including any necessary initialization.