Top Banner
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 3
27

ECE 353 Introduction to Microprocessor Systems

Jan 13, 2016

Download

Documents

Denise Wood

ECE 353 Introduction to Microprocessor Systems. Michael G. Morrow, P.E. Week 3. Objectives. 80C188EB Organization (continued) Segmentation Reset Processing Programmer’s Model 80C188EB Machine Language 80C188EB Assembly Language and Assemblers 80C188EB Debuggers. 80C188EB Architecture. - PowerPoint PPT Presentation
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: ECE 353 Introduction to Microprocessor Systems

ECE 353Introduction to Microprocessor Systems

Michael G. Morrow, P.E.

Week 3

Page 2: ECE 353 Introduction to Microprocessor Systems

Objectives80C188EB Organization (continued) Segmentation Reset Processing Programmer’s Model

80C188EB Machine Language80C188EB Assembly Language and Assemblers80C188EB Debuggers

Page 3: ECE 353 Introduction to Microprocessor Systems

80C188EBArchitecture

Page 4: ECE 353 Introduction to Microprocessor Systems

Segmented Memory Architecture

Memory Segmentation Logical vs. Physical Addresses Segment Organization

Topologies Disjoint Overlapping Identical

Physical Address GenerationAdvantagesDisadvantages

Page 5: ECE 353 Introduction to Microprocessor Systems

80C188EBImplementation

Page 6: ECE 353 Introduction to Microprocessor Systems

80C188EB Programmer’s Model

Accumulator AH AL

BH BL

CH CL

DH DL

SP

BP

SI

DI

CS

DS

ES

SS

F

IP

Data Registers Segment Registers

P ointer & Index Registers Instruction Pointer

Flags Registers

Base

Count

Data

Flags

Stack Pointer

Base Pointer

Source Index

Destination Index

Code

Data

Extra

Stack

BIUEU

Data

Point

er &

Inde

x

Gene

ral p

urpo

se re

giste

rs

AX

BX

CX

DX

Page 7: ECE 353 Introduction to Microprocessor Systems

ProgrammingProgramming Languages HLL Assembly Language Machine Language

Machine Language Instructions 1 – 6 bytes in length Encoding

Page 8: ECE 353 Introduction to Microprocessor Systems

Assembler PrimerAssembler Types Native Assembler Cross Assembler

General Instruction SyntaxInstruction ExamplesAssembler Functions Syntax checking Offset calculation Encoding to machine code

Page 9: ECE 353 Introduction to Microprocessor Systems

ExampleProgram Hardware

Page 10: ECE 353 Introduction to Microprocessor Systems

Source Code File

.186 ;use 80186 instructions

SWITCHES equ 1234h ;define symbolsLEDS equ 5678h

assume cs:code ;establish CS addressability

code segment ;start of code segment

main: mov dx, SWITCHES ;load switch port addressin al, dx ;read switchesnot al ;switch off turns LED onmov dx, LEDS ;load LED port addressout dx, al ;write to LED portjmp main ;and repeat indefinitely

code ends ;end of code segment

end main ;code entry point is at main

Page 11: ECE 353 Introduction to Microprocessor Systems

Assembler Listing File (page 1)

Turbo Assembler Version 4.1 09/12/01 08:49:11 Page 1 week3.ASM

1 .186 ;use 80186 instructions 2 3 =1234 SWITCHES equ 1234h ;define symbols 4 =5678 LEDS equ 5678h 5 6 assume cs:code ;establish CS addressability 7 8 0000 code segment ;start of code segment 9 10 0000 BA 1234 main: mov dx, SWITCHES ;load switch port address 11 0003 EC in al, dx ;read switches 12 0004 F6 D0 not al ;SW=1 --> LED on 13 0006 BA 5678 mov dx, LEDS ;load LED port address 14 0009 EE out dx, al ;write to LED port 15 000A EB F4 jmp main ;and repeat indefinitely 16 17 000C code ends ;end of code segment 18 19 end main ;code entry point is at main

Page 12: ECE 353 Introduction to Microprocessor Systems

Assembler Listing File (page 2)

Turbo Assembler Version 4.1 09/12/01 08:49:11 Page 2Symbol Table

Symbol Name Type Value

??DATE Text "09/12/01"??FILENAME Text "week3 "??TIME Text "08:49:11"??VERSION Number 040A@CPU Text 0103H@CURSEG Text CODE@FILENAME Text WEEK3@WORDSIZE Text 2LEDS Number 5678MAIN Near CODE:0000SWITCHES Number 1234

Groups & Segments Bit Size Align Combine Class

CODE 16 000C Para none

Page 13: ECE 353 Introduction to Microprocessor Systems

Code Generation Process

EDITOR

ASSEMBLER

LINKER

LOCATOR

OBJECT/HEX

source file (*.asm)

relocatable object file (*.obj)

relocatable linked object file (*.obj)

absolute object file (*.axe)

HEX-ASCII object file (*.hex)

DEVICEPROGRAMMER

list file (*.lst)

linker map file (*.map)

locator map file (*.map)

Programmed EPROM

Blank EPROM

Other OBJ filesfrom assembly

or HLL compilers

Page 14: ECE 353 Introduction to Microprocessor Systems

Intel Hex Record Format:020000021000EC:0C000000BA3412ECF6D0BA7856EEEBF4ED:00000001FF

Record Mark

Record Length

Load Address or 0000

Record Type

Data Checksum Record Description

: 02 0000 02 1000 EC Extended address record

: 0C 0000 00 BA3412ECF6D0BA7856EEEBF4

ED Data record

: 02 0000 01 FF End-of-file record

BA3412(mov dx, 1234h)EC(in al, dx)F6D0(not al) BA7856(mov dx, 5678h)EE(out dx, al)EBF4(jmp –12)

Disassembling the data record payload.

Page 15: ECE 353 Introduction to Microprocessor Systems

Borland Development Tools

EDITOR

ASSEMBLERTASM

LINKERTLINK

filename.ASM

filename.OBJ

filename.LST

filename.MAP

Other OBJ filesfrom assembly

DEBUGGERTD filename.EXE

Page 16: ECE 353 Introduction to Microprocessor Systems

Debugger PrimerSo, why is it called a bug, anyway?TerminologyTypical Debugger OperationDebugging Tools Software Hardware

Comparison of Debugging Tools

Page 17: ECE 353 Introduction to Microprocessor Systems

Paradigm C++ Demonstration

Paradigm C++ (PCPP) is used in ECE 315PCPP is an integrated development environment (IDE) Code generation Debugging

Code Development Tips Use structured programming methods / no spaghetti

code. Use descriptive symbols and names. Write comments as you go. When fixing assembler errors, fix only the top one or

two and re-assemble – a lot of the later errors may be due to the first few.

When debugging, verify what the registers are loaded with as compared to what you think they should be loaded with.

Page 18: ECE 353 Introduction to Microprocessor Systems

Instruction Decoding Exercise

The following memory dump was obtained from an 80C188EB-based systemCS:0013 is a valid instructionDecode the memory data to determine the instructions that were assembled to produce it.

CS:0013 B0 12 BA 34 12 FE C7 EB F7

Page 19: ECE 353 Introduction to Microprocessor Systems

Instruction Decoding Solution

16 000A B0 12 Target: mov al, 12h17 000C BA 1234 mov dx, 1234h18 000F FE C7 inc bh19 0011 EB F7 jmp Target

Page 20: ECE 353 Introduction to Microprocessor Systems

Wrapping UpHomework #2 due Friday 9/28

Page 21: ECE 353 Introduction to Microprocessor Systems

80C188EB Instruction Encoding

Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6

LOW DISP/DATA

HIGH DISP/DATA

LOW DATA HIGH DATA

OPCODE D W MOD REG R/M

Register operand/registers to use in EA calculation

Register operand/extension of opcode

Register mode/memory mode with displacement length

Word/byte operation

Direction is to register/direction is from register

Operation (instruction) code [opcode]

Page 22: ECE 353 Introduction to Microprocessor Systems

JMP Instruction Encoding

Page 23: ECE 353 Introduction to Microprocessor Systems

INC Instruction Encoding

Page 24: ECE 353 Introduction to Microprocessor Systems

Debugging Tools

Page 25: ECE 353 Introduction to Microprocessor Systems

Disjoint Segments00000h

FFFFFh

CS

DS

SS

Page 26: ECE 353 Introduction to Microprocessor Systems

Overlapping Segments

CS

DS

SS

00000h

FFFFFh

Page 27: ECE 353 Introduction to Microprocessor Systems

Identical Segments

CS

DS

SS

00000h

FFFFFh