Microcontrollers - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Microcontrollers

Description:

Keep track of the program and interpret instructions. ... Can be loaded into a ROM burner for programming the ROM chip. DB directive ... – PowerPoint PPT presentation

Number of Views:88
Avg rating:3.0/5.0
Slides: 28
Provided by: davidlk2
Category:

less

Transcript and Presenter's Notes

Title: Microcontrollers


1
Microcontrollers
  • 8051 Assembly Language

2
What can the 8051 instructions do?
  • Arithmetic (add, subtract, multiply, divide)
  • Logical Operations (AND, OR, NOT, etc.)
  • Data Transfer (move bytes)
  • Boolean Variable Manipulation (move bits)
  • Program Branching (branch, call subroutines)

3
Why does the uP need registers?
  • Scratch pad.
  • Math.
  • Interface with the outside world.
  • Timing and counting.
  • Keep track of the program and interpret
    instructions.
  • Point to data by holding addresses for easy
    reference.

4
128 Bytes of On Chip RAM
Lower 64 Bytes
Upper 64 Bytes
5
Scratch Pad on Chip RAM
80 byte addressable registers
128 addressable bits
32 register (Rn) addressable bytes
6
The 4 Register Banks.
Numbered 0,1,2, and 3Only 1 at a time can be
activatedBank 0 is the default bank.
Rn
1 byte per register
Ri
7
The Special Function Register Map
(upper 64 bytes of on chip RAM)
Mnemonic Address
Byte Address
Bit Address
8
MOV dest-byte, source-byteCopies bytes from the
source to the destination.
  • MOV A, data
  • MOV A, Rn
  • MOV A, direct
  • MOV A, _at_Ri
  • MOV Rn, A
  • MOV direct, A
  • MOV _at_Ri, A
  • MOV Rn, data
  • MOV Rn, A
  • MOV Rn, direct
  • MOV direct, data
  • MOV direct, _at_Ri
  • MOV direct, Rn
  • MOV _at_Ri, data
  • MOV _at_Ri, A
  • MOV _at_Ri, direct

9
direct addressing
  • direct any 8 bit address 00H to FFH.
  • 2 byte instruction
  • Can be used for any 8-bit address
  • Example MOV A, 45H
  • Copies the contents of RAM location 45H into the
    accumulator.
  • Direct addresses may not start with a letter so
    use a leading zero as in 0E0H instead of E0H.

10
Immediate (data) addressing
  • data 8-bit number 00H to FFH.
  • 10010110B (a binary number)
  • 76H ( a hexadecimal number)
  • 118 ( a decimal number)
  • Example MOV A, 76H
  • Makes the contents of the accumulator become 76H
  • Data may not begin with a letter. Use a leading
    zero as in 0E0H instead of E0H.

11
Register Addressing
  • Rn any register in the selected register bank.
    (n 0,1,2,3,4,5,6,7)

12
Indirect Addressing
  • _at_Ri register 0 or register 1 in the selected
    register bank. ( i 0,1 only)
  • Ri contains the address of the data.

13
ADD A, source-byte
  • Accumulator is always the destination byte.
  • If there is a carry from E7, CY goes high.
  • If there is an overflow, OV goes high.
  • Direct addressing as in ADD A, 7FH
  • Immediate addressing as in ADD A. 7FH

14
The Stack
  • The Stack is a continuous group of RAM memory
    locations.
  • By default, the stack starts at 08H in RAM (Bank
    1) and may extend to RAM address 7FH.
  • Uses the PUSH and POP instructions.
  • PUSH places data on the stack
  • POP takes data from the stack

15
PUSH direct
  • Example PUSH 0E0H
  • Execution
  • First, the stack pointer is incremented (1 is
    added).
  • Second, the contents of RAM memory location E0H
    is copied to the address indicated by the stack
    pointer.

16
POP direct
  • Example POP 0E0H
  • First the contents of the memory location
    indicated by the stack pointer is copied into RAM
    memory location E0H.
  • Second, the stack pointer is decremented (1 is
    subtracted).

17
The programming process
18
.asm files
  • Called the source code.
  • Written in mnemonic form
  • Created with software that is essentially a
    simple word processor.
  • Keyboard entry.

19
.obj files
  • Called theobject file.
  • The output of the assembler.
  • In a format called the machine language

20
.lst file
  • Lists all the opcodes, operands, and addresses.
  • Lists all of the programming syntax errors.

21
Library files
  • Can include any boilerplate code and often used
    subroutines.

22
.abs files
  • Called the absolute file.
  • A marriage of all .obj files that have been
    linked together.

23
.hex file
  • Machine code that appears in hexadecimal form.
  • Can be loaded into a ROM burner for programming
    the ROM chip.

24
DB directive
  • The DB directive tells the assembler that the
    8-bit number that follows is constant data and
    not an instruction.
  • Example DB 28 causes 1CH to be stored in ROM .

25
ORG directive
  • Indicates the beginning address at which the
    program will be placed in ROM.

26
EQU directive
  • Assigns a literal name to to a number.
  • Example THIS_YEAR EQU 2002
  • Before assembly, the number 2002 will replace
    every instance of THIS_YEAR in the program.

27
END directive
  • Indicates the last line of the source code.
Write a Comment
User Comments (0)
About PowerShow.com