Assembly Language An Introduction for ICE4M Teachers - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

Assembly Language An Introduction for ICE4M Teachers

Description:

A Register (Accumulator) B Register. C Register. D Register. E Register. H Register. L Register ... Load Accumulator Extended ... Store Accumulator Extended ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 51
Provided by: cemc2Math
Category:

less

Transcript and Presenter's Notes

Title: Assembly Language An Introduction for ICE4M Teachers


1
Assembly LanguageAn Introduction for ICE4M
Teachers
  • Imperial Oil Summer Institute
  • August 18, 2005
  • Presented by
  • Michelle Vidberg - michelle_at_acse.net

2
Today's Agenda
  • Why teach Assembly Language?
  • High-level vs. low-level languages
  • Choosing a processor
  • CPU registers
  • Introductory commands
  • Types of memory addressing
  • Immediate
  • Direct
  • Indirect
  • Sample programs
  • Oshonsoft software

3
Why Teach Assembly Language?
  • Well, because it's in the curriculum...
  • ICE4M emphasizes the topics
  • - CPU
  • - memory registers
  • - low-level programming

4
By the end of this course, students will
  • describe the constructs of a simple assembly or
    machine-level language
  • identify similarities and differences among
    memory addressing techniques
  • compare high-level and low-level commands that
    perform similar operations.
  • trace the execution of simple machine-level
    programs
  • write low-level programs
  • document all programs to a specified standard.
  • For a complete list of expectations, visit
    http//www.edu.gov.on.ca/eng/document/curricul/sec
    ondary/grade1112/tech/tech.htmlICE4M

5
High-Level vs. Low-Level Languages
  • High-level programming
  • - simple code can be easy-to-interpret
  • total subTotal salesTax
  • put Hello World!
  • for count1..10
  • put count
  • end for

6
  • Computers don't really understand those
    high-level commands until they're translated into
    machine language via the...
  • Compile Process
  • Parsing identifies syntax errors
  • Code Generation translates high-level commands
    into assembly language (depends on CPU)
  • Assembly produces machine language object
    files
  • Linking combines object files into an
    executable file

7
Teachable Moment !!
  • This is a great opportunity to talk about the
    history and development of programming languages.
  • How did people write and store big programs
    before the evolution of high-level languages?
  • This is of particular relevance to those students
    also enrolled in the ICS courses.

8
Machine Language
  • Each machine language line of code has 2 parts
  • - op-code describes the operation to be done
  • - operand identifies the quantity to be
    operated on
  • All commands are in binary, shown grouped as
    hexadecimal digits (4 binary digits 1 hex
    digit)
  • Still quite difficult to read and understand
  • Good applications of binary/hex number systems
    and conversions

9
Machine vs. Assembly Language
  • Assembly language uses alpha-numeric characters
    and more closely resembles English words or
    acronyms.
  • e.g. Move immediate the value 33 into register A
  • in machine language 3E 33
  • in assembly language MVI A 33
  • MVI MoVe Immediate

10
8085 Processor
  • Intel released several 8-bit microprocessors in
    the 1970s including the 8080, 8085, 8088.
  • Simulating a simple processor allows us to show
    the steps, registers, process in a scaled-down
    environment.
  • Choose a processor and a corresponding assembly
    language that suits your needs and has the
    resources you need. (8085 used in profiles and
    here)

11
8085 CPU Registers
12
Introductory Commands
  • MVI Put a specified value in a specified
    register.
  • e.g. MVI A B8 - put B8 in A register
  • MVI B 5F - put 5F in B register

13
8
B
MVI A B8
14
F
5
MVI B 5F
15
  • ADI Add the specified value to register A
  • e.g. ADI 4B
  • SUI Subtract the specified value from register
    A
  • e.g. SUI 12
  • INR Increment specified register by 1
  • e.g. INR C
  • DCR Decrement specified register by 1
  • e.g. DCR B

16
  • LDA Load data into A from given RAM address
  • e.g. LDA 14C3
  • STA Store data from A into given RAM address
  • e.g. STA 2259
  • HLT Halt program

17
Sample Program 1
  • MVI A 33
  • INR A
  • STA 12C3
  • HLT

18
3
3
MVI A 33
19
4
3
INR A
20
12C3
4
3
STA 12C3 HLT
21
Sample Program 2
  • (MVI A 6A)
  • (STA 55C1)
  • LDA 55C1
  • SUI 10
  • STA 55C1
  • HLT

These first 2 lines are somewhat redundant, but
are needed to load 55C1 with a value!
22
55C1
A
6
LDA 55C1
23
A
5
SUI 10
24
55C1
A
5
STA 55C1 HLT
25
Types of Memory Addressing 1
  • Immediate operand is a specific numerical
    value, not an address in RAM
  • e.g. MVI B 52
  • ADI 22
  • SUI FF

26
  • Another Immediate Command
  • Load Extended Immediate (LXI)
  • Loads a pair of registers (BC, DE or HL) with the
    2 bytes specified.
  • e.g. LXI D 3F67
  • - loads D register with value 3F and
  • - loads E register with value 67

27
3
F
6
7
LXI D 3F67
28
Types of Memory Addressing 2
  • Direct operand represents an address in RAM
    (address bus is 16 bits or 2 Bytes)
  • e.g. LDA 55A2
  • STA AB31

29
  • Another Direct Command
  • Load HL Pair Direct
  • LHLD Load value stored at given RAM address
    into L register and load value at next address
    into H register
  • e.g. LHLD 45CD
  • - load value stored at 45CD into register L and
  • - load value stored at 45CE into register H

30
  • Another Direct Command
  • Store HL Pair Direct
  • SHLD Store contents of L register at the
    specified RAM address. Store contents of H
    register at the next adjacent RAM address.
  • e.g. SHLD 6649
  • - store contents of L register at 6649.
  • - store contents of H register at 664A.

31
Types of Memory Addressing 3
  • Indirect operand specifies a pair of registers
    (BC, DE, or HL) where the RAM address of the
    data is stored.

32
  • An Indirect Command
  • Load Accumulator Extended
  • LDAX Loads into register A the data stored at
    RAM address specified by pair of registers
  • e.g. LDAX D
  • Byte from register D and byte from register E are
    put together to make a RAM address. Value stored
    at that RAM address is loaded into register A.

33
A2FF
?
?
A
2
F
F
LDAX D
34
  • Another Indirect Command
  • Store Accumulator Extended
  • STAX Stores value in register A into the RAM
    address specified by pair of registers
  • e.g. STAX B
  • Byte from register B and byte from register C are
    put together to make a RAM address. Value from
    register A is stored at that RAM address.

35
Sample Program 3
  • MVI A 33
  • MVI B 89
  • MVI C 87
  • STAX B
  • HLT

36
3
3
MVI A 33
37
3
3
8
9
MVI B 89
38
3
3
8
9
7
8
MVI C 87
39
8987
3
3
8
9
7
8
STAX B HLT
40
Low-Level Repetition Selection
  • Introduce concept of looping with JMP
  • Every instruction has a memory location (used by
    program counter)
  • e.g. JMP 0033
  • - means jump to instruction at memory location
    0033
  • Must keep track of how much space each
    instruction requires in order to loop to the
    right location

41
Conditional Loops
  • By comparing two values, we cause flags to be set
    in the status register. Based on the result of
    this comparison we can decide to loop or not.
  • 1. Compare another register to A.
  • e.g. CMP C
  • Sets the flags in the status register as if we
    were subtracting contents of C from A. (Does not
    actually subtract)

42
  • 2. Compare an immediate value to register A.
  • e.g. CPI FF
  • Sets the flags in the status register as if we
    were subtracting the value FF from A. (Does not
    actually subtract)

43
  • Now, looking at the flags in the status register,
    we can tell our program to loop under certain
    conditions. (Each command is followed by the
    memory location to jump to)
  • JZ - Jump if Zero
  • JNZ - Jump if Not Zero
  • JP - Jump if Plus
  • JM - Jump if Minus

44
Sample Program 4
  • MVI A 07
  • INR A
  • CPI 0B
  • JNZ ??
  • STA 4400
  • HLT

45
  • 0100 MVI A 07
  • 0102 INR A
  • 0103 CPI 0B
  • 0105 JNZ ??
  • 0108 STA 4400
  • 010A HLT

46
  • 0100 MVI A 07
  • 0102 INR A
  • 0103 CPI 0B
  • 0105 JNZ 0102
  • 0108 STA 4400
  • 010A HLT

47
Recommended Software
  • Oshonsoft 8085 Simulator
  • www.oshonsoft.com
  • 100 U.S. / site licence

48
Recommended Text
  • Networks, Interfaces, Integrated Circuits
  • by Graham Smyth and Christine Stephenson
  • Holt Software Associates, 2002
  • 1-800-361-8324

49
(No Transcript)
50
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com