machine language
Download
Skip this Video
Download Presentation
Machine Language

Loading in 2 Seconds...

play fullscreen
1 / 72

Machine Language - PowerPoint PPT Presentation


  • 86 Views
  • Uploaded on

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 .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Machine Language' - roy


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

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

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

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
    • ii 8-bit immediate data
    • dd low byte of direct address
    • hh ll high and low bytes of extended address
    • ff unsigned 8-bit offset for indexed addressing
    • jj kk high and low bytes of 16-bit immediate data
    • rr signed 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

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

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

basic program
Basic Program
  • Initialize Pointer
  • Initialize Counter
  • Break out of Loop
  • Copy One Entry
  • Advance Pointer
  • Decrement Counter
  • Loop
  • Stop

330_02

limitations and problems
Limitations and Problems
  • Location of Tables
  • Size of Tables
  • Branch Dependency
  • Mixing of program and data

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

ad