Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor.

Similar presentations


Presentation on theme: "EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor."— Presentation transcript:

1 EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor Operation CPU, Memory, I/O, and Buses Machine Code DataTransfer Instructions Addressing Modes

2 EE 362 Microprocessor Systems and Interfacing © 1-2 Von Neumann Architecture Memory Input and Output (I/O) Central Processing Unit (CPU)  arithmetic and logic unit (ALU)  control unit CPU I/O Memory

3 EE 362 Microprocessor Systems and Interfacing © 1-3 Buses Communication is needed among components. Wires connecting the components are called buses. There are three types of buses:  address,  data, and  control. CPUMemoryI/O Address bus Data bus Control bus

4 EE 362 Microprocessor Systems and Interfacing © 1-4 Buses: 68HC12 Address Bus Communication is needed among components. Wires connecting the components are called buses. There are three types of buses:  address, (16 bits)  data,  control. CPUMemoryI/O Address bus Data bus Control bus

5 EE 362 Microprocessor Systems and Interfacing © 1-5 Buses: 68HC12 Data Bus Communication is needed among components. Wires connecting the components are called buses. There are three types of buses:  address,  data, (8 or 16 bits)  control. CPUMemoryI/O Address bus Data bus Control bus

6 EE 362 Microprocessor Systems and Interfacing © 1-6 Buses: 68HC12 Control Bus Communication is needed among components. Wires connecting the components are called buses. There are three types of buses:  address,  data,  control. CPUMemoryI/O Address bus Control bus Data bus

7 EE 362 Microprocessor Systems and Interfacing © 1-7 Computer Operation The computer executes instructions consisting of opcodes and operands, which are stored sequentially in memory as binary numbers. The program counter points to the next instruction to be executed. Operands may be data or addresses or address increments.

8 EE 362 Microprocessor Systems and Interfacing © 1-8 Computer Operation: 68HC12 The computer executes instructions consisting of opcodes and operands, which are stored sequentially in memory as binary numbers. The 68HC12 instruction set contains 209 instructions. The program counter (PC register) points to the next instruction to be executed. The 68HC12 address bus is 16 bits wide so its PC register is a 16-bit register. Operands may contain data or addresses. The number of bytes of operands depends on the instruction.

9 EE 362 Microprocessor Systems and Interfacing © 1-9 Exercise 1.1 What are the three basic components of a microcomputer? What are the three buses in a microcomputer? What is the functionality of each bus? The address bus of the 68HC12 has 16 bits. How many different memory addresses can the 68HC12 access? How many address lines are necessary to address one kilobyte of memory? How many address lines are necessary to address one megabyte memory?

10 EE 362 Microprocessor Systems and Interfacing © HC12 Registers Accumulators A,B and D Index registers IX and IY Program counter PC Stack pointer SP Flag (Condition Code) register CCR Record the size of the following registers: A _______ B ________ D ________ IX _______ IY ________ PC _______ SP ______ Flag ______

11 EE 362 Microprocessor Systems and Interfacing © HC12 Registers Accumulators A,B and D Index registers X and Y Program counter PC Stack pointer SP Flag (Condition Code) register CCR Record the size of the following registers: A 8 bits B 8 bits D 16 bits X 16 bits Y16 bits PC 16 bits SP 16 bits CCR 8 bits

12 EE 362 Microprocessor Systems and Interfacing © HC12 “Model”

13 EE 362 Microprocessor Systems and Interfacing © 1-13 Review: Machine Code What information does the op-code provide? machine instruction to be executed Give an example of an operand. address or data

14 EE 362 Microprocessor Systems and Interfacing © 1-14 Data Transfer Instructions: LDAA LDAA Load Accumulator A LDAA#$32;LDAA is the mnemonic for the ;machine code in computer memory, which is 86;opcode 32;operand After the execution of this instruction, what is the value in accumulator A in hex, binary and decimal? Answer _________ ________ _____________ Write the instruction to load a 2F hex into accumulator A. Answer ______________________ 1-24

15 EE 362 Microprocessor Systems and Interfacing © 1-15 Data Transfer Instructions: LDAA LDAA Load Accumulator A LDAA#$32;LDAA is the mnemonic for the ;machine code in computer memory, which is 86;opcode 32;operand After the execution of this instruction, what is the value in accumulator A in hex, binary and decimal? Answer 32 hex, binary, 50 decimal Write the instruction to load a 2F hex into accumulator A. Answer LDAA #$2F 1-24

16 EE 362 Microprocessor Systems and Interfacing © 1-16 Data Transfer Instructions: LDAB LDAB (Load Accumulator B) Example: LDAB #24 ;assembly instruction Stored as: Location Contents E000C6(Opcode) E00118(Operand)  What is the value in B after instruction execution?  How many memory accesses are required to execute this instruction (assuming the data bus is 16-bit)?  Why are the location addresses 16-bit numbers? 1-26

17 EE 362 Microprocessor Systems and Interfacing © 1-17 Data Transfer Instructions: LDAB LDAB (Load Accumulator B) Example: LDAB #24 ;assembly instruction Stored as: Location Contents E000C6(Opcode) E00118(Operand)  What is the value in B after execution of the instruction? 18 hex  How many memory accesses are required to execute this instruction (assuming the data bus is 16-bit)? 1  Why are the location addresses 16-bit numbers? Address bus is 16-bit. 1-26

18 EE 362 Microprocessor Systems and Interfacing © 1-18 Review: Data Transfer Instructions Write the assembly instruction to load the decimal value 22 into register B. Answer _________ Write the machine code for the above instruction. 1-27

19 EE 362 Microprocessor Systems and Interfacing © 1-19 Review: Data Transfer Instructions Write the assembly instruction to load the decimal value 22 into register B. Answer LDAB #22 or LDAB #$16 Write the machine code for the above instruction. C

20 EE 362 Microprocessor Systems and Interfacing © 1-20 Data Transfer Instructions: LDD LDD (Load Double Accumulator D) Example: LDD #$1024 ;assembly instruction Stored as: Location Contents E000CC(Opcode) E00110(Operand, first byte) E00224(Operand, second byte) What values are in A, B and D? Answers______, _______, ______ Why are two bytes of operands required? How many byte-sized memory accesses are required to execute the instruction? Answer ________ 1-28

21 EE 362 Microprocessor Systems and Interfacing © 1-21 Data Transfer Instructions: LDD LDD (Load Double Accumulator D) Example: LDD #$1024 ;assembly instruction Stored as: Location Contents E000CC(Opcode) E00110(Operand, first byte) E00224(Operand, second byte) What values are in A, B and D? 10, 24, and 1024 hex, respectively Why are two bytes of operands required? D is 16-bit How many byte-sized memory accesses are required to execute the instruction? 3 for code, 2 for data 1-28

22 EE 362 Microprocessor Systems and Interfacing © 1-22 Data Transfer Instructions: LDAA Example: LDAA$1006 Stored as: Location Contents E00086 E00110 E00206 What type of addressing is used? Where does the value to be loaded into A come from? ________ What happens if LDAA #$1006 is attempted? ______ 1-35

23 EE 362 Microprocessor Systems and Interfacing © 1-23 Data Transfer Instructions: LDAA Example: LDAA$1006 Stored as: Location Contents E00086 E00110 E00206 What type of addressing is used? extended Where does the value to be loaded into A come from? memory location 1006 hex What happens if LDAA #$1006 is attempted? error 1-35

24 EE 362 Microprocessor Systems and Interfacing © 1-24 The addressing mode determines how the CPU gets the data it needs to execute an instruction. Types of addressing modes: Examples:  Inherent ABA, DECA, INX  Immediate LDAA #30, LDD #$16  Direct LDD $3f, STX $3f  Extended LDAB $3425  Relative BEQ $10  Indexed ADDA $10,X  Indexed indirect LDAA [D,X] Addressing Modes

25 EE 362 Microprocessor Systems and Interfacing © 1-25 Lecture 2: Development Environment Assembler Assembly Language Fields Constants and Expressions Assembler Directives Linker Development Environment Macros

26 EE 362 Microprocessor Systems and Interfacing © 1-26 Assembler Directives Examples Offset:dc.b6 Count:dc.b$45 Scales:dc.b6,8,30 Msg:dc.b“FEED PART” How many bytes total are reserved above? _________ Assuming Offset starts at $800, what is the value of “Msg” _________ 2-11

27 EE 362 Microprocessor Systems and Interfacing © 1-27 Assembler Directives Examples Offset:dc.b6 Count:dc.b$45 Scales:dc.b6,8,30 Msg:dc.b“FEED PART” How many bytes total are reserved above? = 14 Assuming Offset starts at $800, what is the value of “Msg” 0x = 0x

28 EE 362 Microprocessor Systems and Interfacing © 1-28 Assembler Directives: dc.w dc.w reserves memory space for (16-bit) word constants and specifies their initial values. Mixa:dc.w$2000 Mixb:dc.w$23 Mixc:dc.w$45, 90, $3000 lddMixb How many bytes of memory are reserved? ____ Assuming Mixa is located at $800, what is the value of Mixb in the instruction above? _______ What value is loaded into D in the above instruction? ________ 2-12

29 EE 362 Microprocessor Systems and Interfacing © 1-29 Assembler Directives: dc.w dc.w reserves memory space for (16-bit) word constants and specifies their initial values. Mixa:dc.w$2000 Mixb:dc.w$23 Mixc:dc.w$45, 90, $3000 lddMixb How many bytes of memory are reserved? 2+2+3(2) = 10 Assuming Mixa is located at $800, what is the value of Mixb in the instruction above? 0x0802 What value is loaded into D in the above instruction? $

30 EE 362 Microprocessor Systems and Interfacing © 1-30 Exercise Write the assembler directives to define a constant, named FirstOffset, equal to and to reserve an uninitialized byte-sized memory location named “Offset”. Write the executable assembly code that will read this constant (load the value into a register) and store the value at location “Offset”. 2-15

31 EE 362 Microprocessor Systems and Interfacing © 1-31 Assembler Directive: offset 2-15

32 EE 362 Microprocessor Systems and Interfacing © 1-32 Exercise Write the assembler directives to define a constant, named FirstOffset, equal to and to reserve an uninitialized byte-sized memory location named “Offset”. FirstOffset: equ 25 aOffset: ds.b1 Write the executable assembly code that will read this constant (load the value into a register) and store the value at location “Offset”. LDAA#FirstOffset STAAaOffset 2-15

33 EE 362 Microprocessor Systems and Interfacing © 1-33 Exercise (cont) Show addresses in hex for the following. How many bytes total are reserved? _______ decimal. org0 _____augend:dc.b6,2 _____addend:equ5 _____results:ds.b5 _____store:dc.w$3A,20,$3F2 _____aoffset:dc.b

34 EE 362 Microprocessor Systems and Interfacing © 1-34 Exercise (cont) Show addresses in hex for the following. How many bytes total are reserved? 14 decimal. org0 0x0000augend:dc.b6,2 addend:equ5 0x0002results:ds.b5 0x0007store:dc.w$3A,20,$3F2 0x000Daoffset:dc.b

35 EE 362 Microprocessor Systems and Interfacing © 1-35 Exercise (cont) Considering the previous assembler directives, what are the operands for the following instructions? What values are loaded into the accumulator(s)? Assume the absolute addresses are 0x0800 plus the offset addresses. Answer in hex. Operand LDAAaugend_______ LDAA#addend_______ LDDstore_______ LDD#store _______ LDAAaugend+1_______ 2-17

36 EE 362 Microprocessor Systems and Interfacing © 1-36 Exercise (cont) Assembly Code Machine Code LDAAaugendB LDAA#addend86 05 LDDstoreFC LDD#storeCC LDAAaugend+1B

37 EE 362 Microprocessor Systems and Interfacing © 1-37 Exercise (cont) Assembly Code Register Contents After Execution A B LDAAaugend 06?? LDAA#addend 05?? LDDstore 00 3A LDD#store LDAAaugend

38 EE 362 Microprocessor Systems and Interfacing © 1-38 Linker Command File Exercises Define a code segment called code1 that starts at address address 0x900 and has max size $200 bytes. Define a data segment called const1 that starts immediately after the segment called.text. 2-32

39 EE 362 Microprocessor Systems and Interfacing © 1-39 Linker Command File Exercises Define a code segment called code1 that starts at address address 0x900 and has max size $200 bytes. +seg code1 -b 0x900 -m 0x200 Define a data segment called const1 that starts immediately after the segment called.text. +seg const1 -a.text 2-32

40 EE 362 Microprocessor Systems and Interfacing © 1-40 Miscellaneous $202 = decimal $abcd = % 5 kBytes = bytes decimal If we have 2 Kbytes of memory starting at 0x2000, what is the address of the last byte? Bit0:equ1 Bit2:equ 1 << 2 ldaa #Bit2 ; place ___ in A ldab #~Bit2 ; place ___ in B

41 EE 362 Microprocessor Systems and Interfacing © 1-41 Miscellaneous $202 = 2*16^2+0*16^1+2*16^0 = 514 decimal $abcd = % kBytes = 5*1024 = 5120 bytes decimal If we have 2 Kbytes of memory starting at 0x2000, what is the address of the last byte? 0x27ff (2048=$800) Bit0:equ1 Bit2:equ 1 << 2 ldaa #Bit2 ; place $04 in A ldab #~Bit2 ; place $FB in B


Download ppt "EE 362 Microprocessor Systems and Interfacing © 1-1 Lecture 1: Introduction to Microprocessor Based Systems Microprocessor Architecture Microprocessor."

Similar presentations


Ads by Google