CHAPTER 8. Solutions for Exercises

Similar documents
Exam I Review February 2017

Programming the Motorola MC68HC11 Microcontroller

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

Outline. 2.8 Stack. 2.9 Subroutines

The Motorola 68HC11 Instruc5on Set

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

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

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

Lecture 9 Subroutines

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

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

Microcontrollers and the Freescale/Motorola HC11

EE 42/100 Lecture 25: Binary Signals / Microcontrollers. Rev C 4/26/2012 (9:07 AM) Prof. Ali M. Niknejad

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Using the stack and the stack pointer

Microcontrollers. Microcontroller

Mark II Aiken Relay Calculator

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

538 Lecture Notes Week 3

Introduction to the 9S12 Microcontroller

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

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

Introduction to Microcontrollers


Introduction to 6811 Programming

Sample Problem Set #1

Coe538 Final Study Guide 2016 (Questions & Answers)

MC9S12 Address Space

Computers and Microprocessors

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

Exam 2 E2-1 Fall Name: Exam 2

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE

SECTION 6 CENTRAL PROCESSING UNIT

EE 3170 Microcontroller Applications

538 Lecture Notes Week 5

538 Lecture Notes Week 5

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

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

Introduction to Embedded Microcomputer Systems Lecture 10.1

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

Introduction to Microcontroller. Systems. Embedded system. Assembler or C? Datatypes 2. Datatypes 1

ECE3120: Computer Systems Hardware & Software Development Tools

Addressing Mode Description Addressing Mode Source Format Abbrev. Description

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

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

Exam 2 E2-1 Fall Name: Exam 2

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

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Motorola HC11. Fun with Microcontrollers and Embedded Systems

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

HC11 Instruction Set

Menu. word size # of words byte = 8 bits

Microcomputer Architecture and Programming

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

ECE 4510/5530 Microcontroller Applications Chapter 1

E3940 Microprocessor Systems Laboratory. Introduction to the Z80

538 Lecture Notes Week 1

538 Lecture Notes Week 2

1. Memory Mapped Systems 2. Adding Unsigned Numbers

CPU08RM/AD REV 3 8M68HC08M. CPU08 Central Processor Unit. Reference Manual

Cross Assembly and Program Development

Roberto Muscedere Images and Text Portions 2003 Prentice Hall 1

8051 Overview and Instruction Set

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

Memory & Simple I/O Interfacing

AN1064. Motorola Semiconductor Application Note. Use of Stack Simplifies M68HC11 Programming By Gordon Doughman. Introduction

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

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Microprocessors/Microcontrollers

Dec Hex Bin ORG ; ZERO. Introduction To Computing

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

HC11 Instruction Set Architecture

Lecture 6 Assembly Programming: Branch & Iteration

HC11 Instruction Set Architecture

Lecture 5 Assembly Programming: Arithmetic

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

M. Sc (CS) (II Semester) Examination, Subject: Computer System Architecture Paper Code: M.Sc-CS-203. Time: Three Hours] [Maximum Marks: 60

EE4390 Microprocessors. Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

Microcontroller Intel [Instruction Set]

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

MIGRATING TO THE 68HC12 IN C

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Cmpt 150 The Freescale CPU12 March, The Freescale HC12

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

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.

Freescale Semiconductor, I

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

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

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.

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

instruction 1 Fri Oct 13 13:05:

EE 3170 Microcontroller Applications

2 MARKS Q&A 1 KNREDDY UNIT-I

ME 6405 Introduction to Mechatronics

ECE 331: PC Lab 3 Stack and Subroutines

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

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

Transcription:

CHAPTER 8 Solutions for Exercises E8.1 The number of bits in the memory addresses is the same as the address bus width, which is 20. Thus the number of unique addresses is 2 20 = 1,048,576 = 1024 1024 = 1024K. E8.2 (8 bits/byte) (64 Kbytes) = 8 64 1024 = 524,288 bits E8.3 Because D is a double byte register, two bytes of memory are needed to store its content. Starting from the initial situation shown in Figure 8.9a in the book, execution of the command PSHD results in: 0907: SP 0908: Then the PULX command reads two bytes from the stack and we have: SP 0907: X: 34A2 0908: E8.4 Starting from the initial situation shown in Figure 8.9a in the book, execution of the command PSHD results in: 0907: SP 0908: Then the command PSHA results in: SP 0907: 0908: 34 1

Next the PULX command reads two bytes from the stack and we have: 0907: X: 3434 0908: 34 SP E8.5 The results are given in the book. E8.6 (a) LDAA $0202 This instruction uses extended addressing. The effective address is 0202. In Figure 8.11 we see that this location contains 1A. Thus the content of the A register after this instruction is 1A. (b) LDAA #$43 This instruction uses immediate addressing. The effective address is the one immediately following the op code. This location contains the hexadecimal digits 43. Thus the content of the A register after this instruction is 43. (c) LDAA $05,X This instruction uses indexed addressing. The effective address is the content of the X register plus the offset which is 05. Thus the effective address is 0205. In Figure 8.11 we see that this location contains FF. Thus the content of the A register after this instruction is FF. (d) LDAA $06 This instruction uses direct addressing. The effective address is 0006. In Figure 8.11 we see that this location contains 13. Thus the content of the A register after this instruction is 13. (e) LDAA $07,X This instruction uses indexed addressing. The effective address is the content of the X register plus the offset which is 07. Thus the effective address is 2007. In Figure 8.11 we see that this location contains 16. Thus the content of the A register after this instruction is 16. 2

E8.7 (a) Referring to Table 8.1 in the book, we see that CLRA is the clear accumulator A instruction with a single byte op code 4F. Furthermore execution of this command sets the Z bit of the condition code register. The BEQ $15 command occupies two memory locations with the op code 27 in the first byte and the offset of 15 in the second byte. Thus starting in location 0200, the instructions appear in memory as: 0200: 4F 0201: 27 0202: 14 (b) When the instructions are executed, the CLRA command sets the Z bit. Then if the Z-bit was clear the next instruction would be the one starting in location 0203 following the BEQ $15 command. However since the Z bit is set the next instruction is located at 0203 + 15 = 0218. E8.8 One answer is given in the book. Of course, other correct answers exist. E8.9 One answer is given in the book. Of course, other correct answers exist. Answers for Selected Problems P8.7* P8.9* 262,144 bytes ROM is read-only memory. Some types are: 1. Mask-programmable ROM in which the data is written when the memory is manufactured. 2. Programmable read-only memory (PROM) in which data is written by special circuits that blow tiny fuses or not depending on whether the data bits are zeros or ones. 3. Erasable PROMs (EPROMs) that can be erased by exposure to ultraviolet light (through a window in the chip package) and rewritten using special circuits. 4. Electrically erasable PROMs (EEPROMs) that can be erased by applying proper voltages to the chip. All types of ROM are nonvolatile and are used for program storage in embedded computers. 3

P8.13* In the ignition control system for automobiles, we need to use ROM for the programs and fixed data, because ROM is nonvolatile. Some RAM would be needed for temporary data such as air temperature and throttle setting. Presumably many units would be needed for mass production and mask programmable ROM would be least expensive. P8.19* A digital sensor produces a logic signal or a digital word as its output. An analog sensor produces an analog output signal that varies continuously with the variable being measured. P8.23* A D/A is a digital-to-analog converter that converts a sequence of digital words into an analog signal. They are needed when an analog actuator must be controlled by a digital computer. P8.27* A stack is a sequence of locations in RAM used to store information such as the contents of the program counter and other registers when a subroutine is executed or when an interrupt occurs. Information is added to (pushed onto) the top of the stack and then read out (pulled off) in the reverse order that it was written. After data are pulled off the stack, they are considered to no longer exist in memory. The stack pointer is a register that keeps track of the address of the location immediately above the top of the stack. P8.29* Initially, we have: SP: 004E 004A: 00 004C: 00 004D: 00 004E: 00 4

After the command PSHD, we have: SP: 004C 004A: 00 004C: 00 After the command PSHB we have: SP: 004B 004A: 00 004C: A9 After the command PULA we have: A: A9 0048: 00 SP: 004C 004A: 00 004C: A9 After the command PSHX we have: SP: 004A 004A: 00 X: 34BF 004B: 34 004C: BF 5

P8.31* A sequence of instructions that results in swapping the high and low bytes of the X register is: PSHD save the original contents of A and B PSHX PULD move the content of X to D PSHA PSHB PULX PULD restore contents of A and B P8.32 (a)* LDAA $2002 Extended addressing A:20 (c)* LDAA $04 Direct addressing A:9A (e)* INCA Inherent addressing A:02 (g)* LDAA $2007 Extended addressing A:F3 P8.33 *(a) The command starting at location 200A is the next to be executed after the BMI $07 command. P8.34 Mnemonics Machine codes Memory locations occupied by instruction (a)* CLRA 4F 1 (b)* ADDA $4A 9B 4A 2 P8.36* (a) 48 (b) 09 P8.37* A:14 and B:E0 P8.39* * ANSWER FOR PROBLEM 8.39 ORG 0200 Directive to begin in location 0200 LDAB #$0B 0B is hex equivalent of decimal 11 MUL compute product STD $FF00 store result STOP END 6

P8.41* This subroutine first clears register B which will hold the quotient after the program has been executed. Then 3 is repeatedly subtracted from the content of A, and the content of B is incremented until the value in A is negative. *DIVIDE BY 3 * DIV3 CLRB LOOP SUBA #$03 subtract 3 from content of A. BMI END quit if result is negative INCB JMP LOOP END ADDA #$03 restore remainder to register A RTS 7