Machine language
This presentation is the property of its rightful owner.
Sponsored Links
1 / 72

Machine Language PowerPoint PPT Presentation


  • 48 Views
  • Uploaded on
  • Presentation posted in: General

Machine Language. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. The 68HC11 Microcomputer. Programming Model Memory Model Microprocessor Model Internal Computer Operations Instruction Fetch Instruction Execution Machine Language Programming. Programming Model.

Download Presentation

Machine Language

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Machine language

Machine Language

ELEC 330

Digital Systems Engineering

Dr. Ron Hayne


The 68hc11 microcomputer

The 68HC11 Microcomputer

  • Programming Model

    • Memory Model

    • Microprocessor Model

  • Internal Computer Operations

    • Instruction Fetch

    • Instruction Execution

  • Machine Language Programming

330_02


Programming model

Programming Model

  • Motorola 68HC11 Microcomputer

330_02


Memory model

Memory Model

330_02


Instruction format

Instruction Format

  • Load Accumulator A

    • LDAA $C200

330_02


Microprocessor model

Microprocessor Model

  • Program Counter

  • Instruction Register

  • Accumulators

330_02


Computer operation

Computer Operation

  • Example Instruction (LDAA)

    • Register and Memory contents

330_02


Instruction fetch

Instruction Fetch

  • PC to Memory as Address

    • Read

330_02


Instruction fetch1

Instruction Fetch

  • Memory sends number at address to IR

    • Increment PC

330_02


Instruction fetch2

Instruction Fetch

  • PC to Memory as Address

    • Read

330_02


Instruction fetch3

Instruction Fetch

  • Memory sends number at address to IR

    • Increment PC

330_02


Instruction fetch4

Instruction Fetch

  • PC to Memory as Address

    • Read

330_02


Instruction fetch5

Instruction Fetch

  • Memory sends number at address to IR

    • Increment PC

330_02


Instruction fetch6

Instruction Fetch

  • Register Contents after Fetch

330_02


Instruction execution

Instruction Execution

  • Data Address to Memory

    • Read

330_02


Instruction execution1

Instruction Execution

  • Memory sends data at address to A

330_02


Instruction execution2

Instruction Execution

  • Final Register Contents

330_02


Instruction set table

Instruction Set Table

  • Operand

    • hh ll

    • high and low bytes of address

330_02


Machine language programming

Machine Language Programming

  • N1 + N2  SUM

330_02


Machine language programming1

Machine Language Programming

  • N1 + N2  SUM

330_02


Machine language programming2

Machine Language Programming

  • N1 + N2  SUM

330_02


Machine language programming3

Machine Language Programming

  • N1 + N2  SUM

330_02


Machine language programming4

Machine Language Programming

  • N1 + N2  SUM

330_02


Summary

Summary

  • Programming Model

    • Memory Model

    • Microprocessor Model

  • Internal Computer Operations

    • Instruction Fetch

    • Instruction Execution

  • Machine Language Programming

330_02


Instructions and addressing

Instructions and Addressing

  • Addressing Modes

    • Extended Addressing

    • Direct Addressing

    • Inherent Addressing

    • Immediate Addressing

    • Indexed Addressing

    • Relative Addressing

330_02


Addressing

Addressing

  • Effective Address

    • Address formed by microprocessor as part of instruction execution

  • Addressing Modes

    • Various ways addresses are formed

  • Memory Map

    • Visual technique for understanding implications of addressing modes

330_02


Extended addressing

Extended Addressing

  • Complete 16-bit Address of Data

330_02


Direct addressing

Shortened 8-bit Address

Most-significant byte 00

Address Range

0000 through 00FF

Zero Page Addressing

Shorter and Faster Instructions

Use less memory

Fetched faster

Direct Addressing

330_02


Inherent implied addressing

Some instructions operate on microprocessor registers only

No memory address needed

Example

ABA

A + B  A

Inherent (Implied) Addressing

330_02


Double byte data

Some registers hold 16-bit (double-byte) data

D, X, Y, SP

Example

LDX

M:(M+1)  X

Big-endian convention

High byte at first (lower) address

Low byte at second (higher) address

Double-Byte Data

330_02


Immediate addressing

Constant data placed inside an instruction

No memory address

Fewer bytes of memory

Data immediately available at end of fetch phase

Faster execution

Immediate Addressing

330_02


Indexed addressing

Op Code and Offset Byte

Effective Address

Offset (unsigned) added to Index Register (pointer)

Index Register unchanged

Example

LDAA 2,X

M[2+X]  A

Indexed Addressing

330_02


Relative addressing

Relative Addressing

  • Branch Instructions

    • Make decisions

    • Alter program flow

  • Condition Code Register

    • Reports test results

330_02


Condition code bits

C (Carry)

Carry-out from the most-significant bit

V (Overflow)

Two’s complement overflow error

Z (Zero)

Result contains all zeros

N (Negative)

Result is negative

H (Half-carry)

Carry from halfway (bit 3)

Generally used only with BCD numbers

S, X, I

Hardware control bits (later...)

Condition Code Bits

330_02


Example

Example

  • ADDA

330_02


Condition code notation

Condition Code Notation

  • Not all instructions affect all the condition code bits

  • Always use the instruction set table to determine how the bits work

    • Don’t assume!

330_02


Branch instructions

May alter program flow based on the condition code bits

Program Counter

Relative Addressing

Signed Offset

Effective Address

PC plus Offset

Branch Range?

Branch Instructions

330_02


Branch not equal to zero

BNE

Branch if Not = Zero

? Z = 0

Example

LDAA N1

LOOP ADDA #-1

BNE LOOP

STOP

Branch Not Equal to Zero

330_02


Addressing mode summary

Addressing Mode Summary

330_02


Addressing mode summary1

Addressing Mode Summary

330_02


Basic instructions

Basic Instructions

  • Arithmetic and Logic

  • Load and Store

    • Input and Output

  • Testing and Branching

330_02


Programming model1

Programming Model

  • Motorola 68HC11 Microcomputer

330_02


Instruction set table1

Instruction Set Table

  • Source Form

    • Instruction mnemonic

    • Type of operand

      • (opr)data or data address

      • (rel)relative offset

  • Operation

    • Short word description

  • Booelan Expression

    • Detailed description of register transfers

  • Addressing Mode

330_02


Instruction set table2

Instruction Set Table

  • Op Code

    • Machine code for corresponding addressing mode

  • Operand

    • ii8-bit immediate data

    • ddlow byte of direct address

    • hh llhigh and low bytes of extended address

    • ffunsigned 8-bit offset for indexed addressing

    • jj kkhigh and low bytes of 16-bit immediate data

    • rrsigned 8-bit relative offset for branch

330_02


Instruction set table3

Instruction Set Table

  • Bytes

    • Number of bytes of memory (op code + operand)

  • Cycles

    • Number of clock cycles to fetch and execute

  • Condition Codes

330_02


Instruction set table4

Instruction Set Table

330_02


Instruction set table cont

Instruction Set Table (cont)

330_02


Arithmetic and logic

Arithmetic and Logic

  • ABA

    • Add B to A

  • ABX

    • Add B to X

  • ADDA, ADDB, ADDD

    • Add memory to accumulator

  • ADCA, ADCB

    • Add memory with carry to accumulator

330_02


Arithmetic and logic1

Arithmetic and Logic

  • DEC, DECA, DECB

    • Decrement memory or accumulator

  • DEX

    • Decrement X

  • INC, INCA, INCB

    • Increment memory or accumulator

  • INX

    • Increment X

330_02


Arithmetic and logic2

Arithmetic and Logic

  • NEG, NEGA, NEGB

    • Negate memory or accumulator

  • SBA

    • Subtract B from A

  • SBCA, SBCB

    • Subtract with carry

  • SUBA, SUBB, SUBD

    • Subtract memory from accumulator

330_02


Arithmetic and logic3

Arithmetic and Logic

  • COM, COMA, COMB

    • Complement memory or accumulator

  • ANDA, ANDB

    • AND memory with accumulator

  • ORAA, ORAB

    • OR memory with accumulator

  • EORA, EORB

    • Exclusive OR memory with accumulator

330_02


Load and store

Load and Store

  • LDAA, LDAB, LDD, LDX

    • Load accumulator or index register from memory

  • STAA, STAB, STD, STX

    • Store accumulator or index register into memory

  • TAB, TBA

    • Transfer (copy) A to B or B to A

  • TPA

    • Transfer condition codes to A

330_02


Testing and branching

TST, TSTA, TSTB

Test memory or accumulator

CLR, CLRA, CLRB

Clear memory or accumulator

CLC, CLV

Clear the carry or overflow

SEC, SEV

Set the carry or overflow

BRA

Branch always

Relative addressing

JMP

Jump (always)

Extended, indexed addressing

NOP

No operation

Testing and Branching

330_02


Testing and branching1

BMI

Branch on minus

BPL

Branch on plus

BEQ

Branch on equal to zero

BNE

Branch on not equal to zero

BCC

Branch on carry clear

BCS

Branch on carry set

BVC

Branch on overflow clear

BVS

Branch on overflow set

Testing and Branching

330_02


Comparison branching

Comparison Branching

  • CBA

    • Compare B to A

  • CMPA, CMPB

    • Compare accumulator to memory

  • CPX

    • Compare X to memory

  • SBA, SUBA, SUBB

    • Subtraction

330_02


Comparison branching1

BGT

Branch if greater than

BGE

Branch if greater than or equal to

BLT

Branch if less than

BLE

Branch if less than or equal to

BHI

Branch if higher

BHS

Branch if higher or same

BLO

Branch if lower

BLS

Branch if lower or same

Comparison Branching

330_02


Instruction summary

Instruction Summary

  • Arithmetic and Logic

  • Load and Store

    • Input and Output

  • Testing and Branching

330_02


Machine language programming5

Machine Language Programming

  • Minimum Requirements of a Good Program

  • Example

    • Copy a Table

  • Basic Program Loop

    • Pointer

    • Counter

330_02


Minimum requirements of a good program

Minimum Requirements of a Good Program

  • The program must:

    • do the same thing every time

    • not modify itself

    • work correctly for all reasonable data values

  • The program should:

    • separate instructions and data in memory

    • adapt easily to different sets of data

    • start at the first instruction and stop at the last

330_02


Copy a table example

Copy a Table Example

330_02


Brainstorming

Brainstorming

  • Possible Approaches

    • Copy-a-table Instruction

    • Copy a Memory Byte

    • Load and Store

    • A Loop

330_02


Basic program loop

Basic Program Loop

  • Pointer

    • Points to the table entry to be copied

    • Index Register X

  • Counter

    • Counts entries to be copied

    • Memory Register

  • Counting Method

    • Initialize to number of entries

    • Decrement to zero

330_02


Pointer and counter

Pointer and Counter

330_02


Basic program

Basic Program

  • Initialize Pointer

  • Initialize Counter

  • Break out of Loop

  • Copy One Entry

  • Advance Pointer

  • Decrement Counter

  • Loop

  • Stop

330_02


Copy table program

Copy Table Program

330_02


Copy table program1

Copy Table Program

330_02


Limitations and problems

Limitations and Problems

  • Location of Tables

  • Size of Tables

  • Branch Dependency

  • Mixing of program and data

330_02


Improved copy table program

Improved Copy Table Program

330_02


Improved copy table program1

Improved Copy Table Program

330_02


Improved copy table program2

Improved Copy Table Program

330_02


Improved copy table program3

Improved Copy Table Program

330_02


Summary1

Summary

  • Minimum Requirements of a Good Program

  • Basic Program Loop

    • Pointer

    • Counter

  • Example

    • Copy a Table

    • Improved Copy Table Program

330_02


  • Login