Top Banner
ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 1 LA TROBE UNIVERSITY DEPARTMENT OF ELECTRONIC ENGINEERING ELECTRONICS-2 Microprocessors: Lecture 2 Introduction to the 68HC11 Architecture and Instruction Set Arithmetic Revision: Hexadecimal & Binary Arithmetic Add Complement Subtract Shift Left CPU operation: Address Buss, Data Bus, ALU, Instruction Pointer, Memory Address Register (MAR) Fetch-Execute cycle Jump Introduction to MC68HC11 Instruction set : Registers, Load, store, transfer, exchange, Addressing Modes Definition of common Terms: Data A collection of information Program A sequence of instructions Processor A processor is an electronic device capable of manipulating data in a way specified by a program. A processor requires: memory for program and data storage, support logic, I/O Co-Processor A cooperating processor with restricted functionality e.g. Intel 80387 floating point math co-processor, DMA controller, IO controller, etc
17

Lecture 2 Introduction to the 68HC11 Architecture and ...

May 03, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 1

LA TROBE UNIVERSITY DEPARTMENT OF ELECTRONIC ENGINEERING

ELECTRONICS-2

Microprocessors: Lecture 2

Introduction to the 68HC11 Architecture and Instruction Set

Arithmetic Revision: Hexadecimal & Binary Arithmetic

AddComplement SubtractShift Left

CPU operation: Address Buss,Data Bus, ALU, Instruction Pointer, Memory Address Register (MAR)Fetch-Execute cycleJump

Introduction to MC68HC11 Instruction set : Registers, Load, store, transfer, exchange, Addressing Modes

Definition of common Terms:

Data A collection of information

Program A sequence of instructions

Processor A processor is an electronic device capable of manipulating data in a way specified bya program. A processor requires: memory for program and data storage, support logic,I/O

Co-Processor A cooperating processor with restricted functionality e.g. Intel 80387 floating pointmath co-processor, DMA controller, IO controller, etc

Page 2: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 2

MicroProcessor (uP) A Microprocessor is a CPU implemented on (usually) one integrated circuit. Itnormally contains CPU - Instruction fetch, execution, interrupt and management ofaddresse, data & control lines which are connected to the chip. (Ref 4)

MicroController (MCU)A microcontroller is a microelectronic chip incorporating a uP, memory,communications and other support functions (eg ADC, Timers etc) (Ref 4)

Von Neumann architectureThe computer follows a step-by-step program that governs its operation.The program is stored as dataData is read from and written to memory. Instructions are read from memory.There is no distinction between data and instructions. An instruction may be treated as data.

Harvard ArchitectureSeparate data and program code address spaces.The program is stored in its own address space.

Complex Instruction Set Computer - CISC The instruction set is large, and offers great variety of instructions (100 or soinstruction types, many addressing modes).Few instructions complete in one cycle

Reduced Instruction Set Computer - RISCThe instruction set is small, and most instructions complete in one cycle (30 or soinstruction types, limited addressing modes). Often implemented using HarvardArchitecture.

Digital Signal ProcessorSpecial purpose uP with an architecture suitable for fast execution of signal processingalgorithms.

Neural computer (also known as a neural network or connectionist system) - Its operation is determined by the input patterns to a system of processing elementsbased on the functionality of the human neuron. The neural computer is non-programmable (in the traditional sense), instead it learns from experience how tofunction.

The 68HC11 belongs is a special type of microprocessor known as a microcontroller. It is designed for industrial control applications, but has many uses.It is an 8 bit microprocessor of the 6800 family with small inbuilt memory (RAM, ROM andEEPROM), Parallel & Serial IO, Analog to Digital Converter, Timers & Counters

Page 3: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 3

Programs

Instructions are read from memory like data.(Fetch)

As each instruction is decoded, it causes the processor to perform a given operation.(Execute)

A self-contained sequence of instructions is a program.

The 68HC11 processor fetches and executes one instruction at a time.

Programs are also know as software.

The electronic components that make up a computer are called hardware.

When programs are stored in ROM (EPROM or FLASH) memory they are called Firmware

Addresses are numbers that point to locations in memory.

The 68HC11 has a 16-bit address bus, which means it can directly address 65536 (decimal)memory locations. This is 64k locations. It is therefore said to have a 64k address space.

Its address range is from 000016 to FFFF16.

Buses are the transportation vehicles for (electrical) signals, including both data andinstructions,

between registers, registers and memory locations,and among memory locations

The 68HC11, is an 8-bit processor -thedata bus is 8 bits wide and theaddress bus consists of 16 bits

RegistersRegisters are the internal storage of aprocessor. They hold the data theprocessor is currently using.

For a processor to manipulate the dataat a given location in memory, that datamust first be loaded into a register. Thedata is then manipulated according tothe current instruction.

Registers may hold data, addresses orstatus information.

Page 4: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 4

?

Figure 2 MCU diagram showing multiplexed address bus and data bus. (Time share)

Page 5: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 5

OctalHexadecimalBinaryDecimal00000001100011220010233001134401004550101566011067701117

108100081191001912A10101013B10111114C11001215D11011316E11101417F111115

Fundamental Data Types

Digital Computers work in the binary number system.

The basic unit is the bit ("BInary digIT") A bit can be either 1 or 0

Fundamental data types are Integer, Real Number (floating point), Character & Boolean.

Abstract data types can be created by defining some composition of fundamental data typeswith operations. (Eg enumerations/sets, records, arrays, lists)

The other basic units are:Nybble 4 bits 0000 - 1111 (Binary),

0, 1, 2, ...E, F (Hex)Byte or Character

8 bits 0000 0000 - 1111 1111 (Binary), 00 - FF (Hex)

Word The word size of a computer is determined by the number of bits that can bemanipulated and stored in registers.

For a 16 bit computer:Word 16 bits 0000 - FFFF (Hex)Doubleword 32 bits 0000 0000 -

FFFF FFFF (Hex)For a 32 bit computer:Word 32 bits 0000 0000 - FFFF FFFF (Hex)Doubleword 32 bits 0000 0000 0000 0000 -

FFFF FFFF FFFF FFFF (Hex)Hexadecimal, Binary & Octal

Page 6: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 6

Signed Number Representation

Hex numbers may be signed or unsigned.Unsigned numbers are positive only.

For 8 bits, they range from 0 .. 255 (0..FF16)

Signed numbers are positive, negative or zero. The most significant bit is used to represent the sign of a number

For 8 bits, they range from -128 ..127 (80..7F hex)

Negative Number representationByte numeric representation (8 bits = 1 byte)

Signed Unsigned Binary Hexadecimal Octal+127 127 0111 1111 7F 177-128 128 1000 0000 80 200-4 252 1111 1100 FC 374-3 253 1111 1101 FD 375-2 254 1111 1110 FE 376-1 255 1111 1111 FF 377

If we look at 128 above, how can we tell if that is a signed or unsigned number? We cant. We need to decide that we are dealing with a signed or unsigned number and treat it in theappropriate way. This can be a source of bugs! Using a C compiler is a way to pass off theresponsibility of management of the nature of numbers. In assembly language we need to beaware of the signed/unsigned nature of each variable and choose the appropriate operation.

Hex & Binary NotationNormally hexadecimal numbers often have either

a dollar sign '$' (eg AS11) or a ’0x' (as in the ‘C’ language)or an ‘H’ suffix (as in MASM/TASM) to indicate their base is 16.

However, when using the BUFFALO assemble command, the computers we will assume thatall numbers are hex and so use no indicator. When using the AS11 assembler, a $ prefix isrequired to indicate the number is hexadecimal.

Binary numbers may have a ‘%’ sign prefix or a ‘B’ suffix to indicate their base. eg:%01101101, or 01101101B (MASM / TASM).

(In 1937 Claude Shannon published the principles of an electric adder for base 2.)

Page 7: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 7

Binary Addition0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1,1 + 1 = 0, Carry 1

One's complement

Invert bits - The NOT operation is performed

invert 1101 0101 -> 0010 1010

Twos complement example 1Take one's complement of a number and then add 1.

Twos complement To convert from positive integer to negative integerTo convert from negative integer to positive integer

Example:

To Negate the byte 1101 0101 = C516 = -43 DecimalInvert each bit

-> 0010 1010 Then add 1 + 0000 0001

-> 0010 1011 = 2B16 =43 Decimal

Is this the answer that the Microsoft Calculator gave? Why not?

Two's complement example 2Start with 0000 0011 = 3 DecimalOne's complement 1111 1100

Add 1-> 1111 1101 = -3 Decimal

Two's complement example 3Start with 0000 0000 = 0 One's complement 1111 1111

Add 10000 0000 = 0

So negating 0 gives 0. This is useful.

Page 8: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 8

The ASCII Character SetDefines the first 128 Characters. The first 32 are ‘control’ characters.

The Extended IBM Graphics Character Set Extended on ASCII to define the second 128 Characters, from 80H-FFH.

0123456789ABCDEFDec Hex Text Name Control --- --- ---- -------- 0 0 0x00 NUL Null character ^@ 1 1 0x01 SOH Start of heading ^A 2 2 0x02 STX Start of text ^B 3 3 0x03 ETX End of text ^C 4 4 0x04 EOT End of transmission ^D 5 5 0x05 ENQ Enquiry ^E 6 6 0x06 ACK Acknowledgement ^F 7 7 0x07 BEL Bell ^G 8 8 0x08 BS Backspace ^H 9 9 0x09 HT Horizontal tab ^I A 10 0x0A LF Line feed ^J B 11 0x0B VT Vertical tab ^K C 12 0x0C FF Form feed ^L D 13 0x0D CR Carriage return ^M E 14 0x0E SO Shift out ^N F 15 0x0F SI Shift in ^O 16 0x10 DLE Data link escape ^P 17 0x11 DC1 Device control 1 ^Q Extended IBM character set. 18 0x12 DC2 Device control 2 ^R 19 0x13 DC3 Device control 3 ^S 20 0x14 DC4 Device control 4 ^T 21 0x15 NAK Negative ack ^U 22 0x16 SYN Synchronize ^V 23 0x17 ETB End of transmission ^W 24 0x18 CAN Cancel ^X 25 0x19 EM End of medium ^Y 26 0x1A SUB Substitute ^Z 27 0x1B ESC Escape 28 0x1C FS Form separator 29 0x1D GS Group separator 30 0x1E RS Record separator 31 0x1F US Unit separator 32 0x20 SP Space

Page 9: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 9

Normal ASCII Characters:

33 0x21 ! Exclamation mark 72 0x48 H H

34 0x22 " Quotation mark 73 0x49 I I

35 0x23 # CrossHatch/Pound 74 0x4A J J

36 0x24 $ Dollar 75 0x4B K K

37 0x25 % Percent 76 0x4C L L

38 0x26 & Ampersand 77 0x4D M M

39 0x27 ' Apostrophe 78 0x4E N N

40 0x28 ( Left parenthesis 79 0x4F O O

41 0x29 ) Right parenthesis 80 0x50 P P

42 0x2A * Asterisk 81 0x51 Q Q

43 0x2B + Plus sign 82 0x52 R R

44 0x2C 83 0x53 S S

45 0x2D - Hyphen 84 0x54 T T

46 0x2E . Period 85 0x55 U U

47 0x2F / Virgule 86 0x56 V V

48 0x30 0 Zero 87 0x57 W W

49 0x31 1 One 88 0x58 X X

50 0x32 2 Two 89 0x59 Y Y

51 0x33 3 Three 90 0x5A Z Z

52 0x34 4 Four 91 0x5B [ Left bracket

53 0x35 5 Five 92 0x5C \ Backslash

54 0x36 6 Six 93 0x5D ] Right bracket

55 0x37 7 Seven 94 0x5E ^ Circumflex

56 0x38 8 Eight 95 0x5F _ Underscore

57 0x39 9 Nine 96 0x60 ` Grave

58 0x3A : Colon 97 0x61 a a

59 0x3B ; Semicolon 98 0x62 b b

60 0x3C < Less-than symbol 99 0x63 c c

61 0x3D = Equal sign 100 0x64 d d

62 0x3E > Greater-than symbol 101 0x65 e e

63 0x3F ? Question mark 102 0x66 f f

64 0x40 @ Commercial AT sign

103 0x67 g g

65 0x41 A A 104 0x68 h h

66 0x42 B B 105 0x69 i i

67 0x43 C C 106 0x6A j j

68 0x44 D D 107 0x6B k k

69 0x45 E E 108 0x6C l l

70 0x46 F F 109 0x6D m m

Page 10: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 10

71 0x47 G G 110 0x6E n n

112 0x70 p p

113 0x71 q q

114 0x72 r r

115 0x73 s s

116 0x74 t t

117 0x75 u u

118 0x76 v v

119 0x77 w w

120 0x78 x x

121 0x79 y y

122 0x7A z z

123 0x7B { Left brace

124 0x7C | Vertical bar

125 0x7D } Right brace

126 0x7E ~ Tilde

127 0x7F DEL Delete

Masking Bits

Page 11: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 11

N

otation

Page 12: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 12

Page 13: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 13

68HC11 Register Set

Condition Codes Register (CCR)There are 8 Flag bits identified by letters as follows:S X H I N Z V C

The Flag bits hold the results of recent Arithmetic, Logical and control operations in the CPU.N Negative result - Reflects MSB of last ALU result Z Zero result - Set when the ALU result is 0 (byte = 0000 0000)V oVerflow - Twos complement overflowC Carry (or borrow) - Used with shift & rotate instruction error flag for MUL & DIV instructions.

Page 14: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 14

Condition Codes Register (CCR) Continued.

Conditional Branch Instructions

Using the value stored in the bits of the condition codes register, the programs flow of controlcan be altered.

FOR EXAMPLEIn the ‘C’ language we could write something like this:char myChar; define myChar as a character.....IF (myChar > ‘F’) goto mylabel;

do_something();myLabel:

This could be performed in assembly language like this:

myChar RMB 1 ; reserve 1 memory byte ....LDAA myInt ; Load myInt from memory into the A registerCMPA ‘F’ ; Subtract the value in Accumulator A is from the ASCII character FBGT myLabel ; Branch if the result is Greater Than 0, to myLabel.JSR do_something my_Label:

Page 15: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 15

Conditional Branches

Condition Code Altering Instructions

These instructions allow the programmer to change one or all bits in the Condition CodesRegister:

68HC11 CPU Condition CodesRegister: ZERO FLAG

Page 16: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 16

Page 17: Lecture 2 Introduction to the 68HC11 Architecture and ...

ELE22MIC Microprocessors Aug 2004 Lecture 2 Page 17

References

1. Notes revised by Paul Main, 2004, drawing from material originally written by JohnCatsoulis and Sen Goh

2. Most images are courtesy of Motorola technical data sheets 11A8TD.PDF and 11RM.PDF

3. Refer to web resources at: http://thor.ee.latrobe.edu.au/~pmain/

4. Richard Dorf., “The IEEE Electrical Engineering Handbook”, CRC Press, 1993.