Von Neumann Architecture Memory Input and Output IO







































- Slides: 39

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

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

Buses: 68 HC 12 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. Address bus Data bus Control bus EE 362 Microprocessor Systems and Interfacing © 1 -4

Buses: 68 HC 12 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. Address bus Data bus Control bus EE 362 Microprocessor Systems and Interfacing © 1 -5

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

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. EE 362 Microprocessor Systems and Interfacing © 1 -7

Computer Operation: 68 HC 12 The computer executes instructions consisting of opcodes and operands, which are stored sequentially in memory as binary numbers. The 68 HC 12 instruction set contains 209 instructions. The program counter (PC register) points to the next instruction to be executed. The 68 HC 12 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. EE 362 Microprocessor Systems and Interfacing © 1 -8

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

68 HC 12 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 ______ EE 362 Microprocessor Systems and Interfacing © 1 -10

68 HC 12 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 Y 16 bits PC 16 bits SP 16 bits CCR 8 bits EE 362 Microprocessor Systems and Interfacing © 1 -11

68 HC 12 “Model” EE 362 Microprocessor Systems and Interfacing © 1 -12

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

Data Transfer Instructions: 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 2 F hex into accumulator A. Answer EE 362 Microprocessor Systems and Interfacing © ___________ 1 -14 1 -24

Data Transfer Instructions: 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, 0011 0010 binary, 50 decimal Write the instruction to load a 2 F hex into accumulator A. Answer LDAA #$2 F EE 362 Microprocessor Systems and Interfacing © 1 -15 1 -24

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

Data Transfer Instructions: LDAB (Load Accumulator B) Example: LDAB #24 ; assembly instruction Stored as: Location Contents E 000 C 6 (Opcode) E 001 18 (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 EE 362 Microprocessor Systems and Interfacing © Why are the location addresses 16 -bit 1 -17 1 -26

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. EE 362 Microprocessor Systems and Interfacing © 1 -18 1 -27

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 6 16 EE 362 Microprocessor Systems and Interfacing © 1 -19 1 -27

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

Data Transfer Instructions: LDD (Load Double Accumulator D) Example: LDD #$1024 ; assembly instruction Stored as: Location Contents E 000 CC (Opcode) E 001 10 (Operand, first byte) E 002 24 (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. EE 362 Microprocessor Systems and Interfacing © How many byte-sized memory accesses are 1 -21 1 -28

Data Transfer Instructions: LDAA Example: LDAA $1006 Stored as: Location Contents E 000 86 E 001 10 E 002 06 What type of addressing is used? Where does the value to be loaded into A come from? ____ What happens if LDAA #$1006 is attempted? ______EE 362 Microprocessor Systems and Interfacing © 1 -22 1 -35

Data Transfer Instructions: LDAA Example: LDAA $1006 Stored as: Location Contents E 000 86 E 001 10 E 002 06 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 EE 362 Microprocessor Systems and Interfacing © 1 -23 1 -35

Addressing Modes 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 $3 f, STX $3 f Extended LDAB $3425 Relative BEQ $10 EE 362 Microprocessor Systems and Interfacing © 1 -24

Assembler Directives Examples Offset: dc. b 6 Count: dc. b $45 Scales: dc. b 6, 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” _____ EE 362 Microprocessor Systems and Interfacing © 1 -26 2 -11

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

Assembler Directives: dc. w reserves memory space for (16 -bit) word constants and specifies their initial values. Mixa: Mixb: Mixc: dc. w $2000 $23 $45, 90, $3000 ldd Mixb 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? ____ EE 362 Microprocessor Systems and Interfacing © 1 -28 2 -12

Assembler Directives: dc. w reserves memory space for (16 -bit) word constants and specifies their initial values. Mixa: Mixb: Mixc: dc. w $2000 $23 $45, 90, $3000 ldd Mixb 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? 0 x 0802 What value is loaded into D in the above instruction? EE 362 Microprocessor Systems and Interfacing © $0023 1 -29 2 -12

Exercise Write the assembler directives to define a constant, named First. Offset, equal to 2510 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”. EE 362 Microprocessor Systems and Interfacing © 1 -30 2 -15

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

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

Exercise (cont) Show addresses in hex for the following. How many bytes total are reserved? _______ decimal. _____ _____ org augend: addend: results: store: aoffset: 0 dc. b equ ds. b dc. w dc. b 6, 2 5 5 $3 A, 20, $3 F 2 20 EE 362 Microprocessor Systems and Interfacing © 1 -33 2 -16

Exercise (cont) Show addresses in hex for the following. How many bytes total are reserved? 14 decimal. org 0 0 x 0000 augend: dc. b addend: equ 5 0 x 0002 results: ds. b 0 x 0007 store: dc. w 0 x 000 D aoffset: dc. b 6, 2 5 $3 A, 20, $3 F 2 20 EE 362 Microprocessor Systems and Interfacing © 1 -34 2 -16

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 0 x 0800 plus the offset addresses. Answer in hex. Operand LDAA augend _______ LDAA #addend _______ LDD store _______ LDD #store _______ LDAA augend+1 _______ EE 362 Microprocessor Systems and Interfacing © 1 -35 2 -17

Exercise (cont) Assembly Code LDAA LDD LDAA augend #addend store #store augend+1 Machine B 6 08 00 86 05 FC 08 07 CC 08 07 B 6 08 01 EE 362 Microprocessor Systems and Interfacing © 1 -36 2 -17

Exercise (cont) Assembly Code Contents Register After Execution A B LDAA LDD LDAA augend #addend store #store augend+1 06 ? ? 05 ? ? 00 3 A 08 07 02 07 EE 362 Microprocessor Systems and Interfacing © 1 -37 2 -17

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

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

Miscellaneous $202 = decimal $abcd = % 5 k. Bytes = bytes decimal If we have 2 Kbytes of memory starting at 0 x 2000, what is the address of the last byte? Bit 0: Bit 2: equ 1 << 2 ldaa #Bit 2 ; place ___ in A ldab #~Bit 2 ___ in BEE 362 Microprocessor Systems and Interfacing © ; place 1 -40

Miscellaneous $202 = 2*16^2+0*16^1+2*16^0 = 514 decimal $abcd = %1010 1011 1100 1101 5 k. Bytes = 5*1024 = 5120 bytes decimal If we have 2 Kbytes of memory starting at 0 x 2000, what is the address of the last byte? 0 x 27 ff (2048=$800) Bit 0: Bit 2: equ 1 << 2 ldaa #Bit 2 ; place $04 in A ldab #~Bit 2 EE 362 Microprocessor Systems and Interfacing © ; place 1 -41