Microprocesadores

Páginas: 6 (1488 palabras) Publicado: 9 de febrero de 2012
8051 Microcontroller – Architecture, Intro to Assembly Programming
EE4380 Fall 2002 Class 2

Pari vallal Kannan
Center for Integrated Circuits and Systems University of Texas at Dallas

Class –2: Objective
l l l l l l

8051 internal architecture Register Set Instruction Set Memory Map Intro to Stack, SFRs Assembly language programming

21-Jan-03

2

8051 Architecture
lProgrammer’s View
– – –

Register Set Instruction Set Memory map Pinout Timing characteristics Current / Voltage requirements

l

Hardware Designer’s View
– – –

21-Jan-03

3

Programmer’s View – Register Set
l

Registers
– – – – – – –

A, B, R0 to R7 : 8 bit registers DPTR : [DPH:DPL] 16 bit register PC : Program Counter (Instruction Ptr) 16bits 4 sets of register bank R0-R7 Stackpointer SP PSW : Program Status Word (a.k.a Flags) SFR : Special Function Registers
l

Control the on-board peripherals

21-Jan-03

4

Assembly – Absolute Basics
l l l l

Intel Assembly format
Operation destination source


; comment

Values are to be preceded by a # sign
#55, #32 etc #55H, #32H

Hex values are to be followed by H


If the first figure in a hex quantityis a letter (AF) then a 0 must precede it


#0FFH, #0C1H, #0D2H

21-Jan-03

5

Register Set – Accumulator A, ACC
l l

Commonly used for moving data around, logic and arithmetic operations on 8bit data Examples
mov A, R0 push ACC mov A, #10 mov B, A mov A, 10 mov A, 0xFF mov A, 0FFH ;copy contents of R0 to A ;store A onto stack ;A ß 10 ;B ß A ;A ß mem(10) ;A ß 0xFF ;same as above21-Jan-03

6

Register Set – B Register
l l l

Commonly used as a temporary register, much like a 9th R register Used by two opcodes


mul AB, div AB

B register holds the second operand and will hold part of the result
– –

Upper 8bits of the multiplication result Remainder in case of division

21-Jan-03

7

Register Set – R0 to R7
l l l l l l

Set of 8 registers R0,R1, … R7, each 8 bit wide Widely used as temporary registers Available in 4 banks (effectively 4x8 registers) Bank is chosen by setting RS1:RS0 bits in PSW Default bank (at power up) is the bank0 Examples
mov R0, A mov A, R0 mov R1, #45 ;R0 ß A ;A ß R0 ;R1 ß 45

21-Jan-03

8

Registers - DPTR
l l l

16 bit register, called Data Pointer Used by commands that access external memory Alsoused for storing 16bit values
mov DPTR, #data16 movx A, @DPTR ; setup DPTR with 16bit ext address ; copy mem[DPTR] to A

l

DPTR is useful for string operations, look up table (LUT) operations

21-Jan-03

9

Registers - PC
l l l l

PC is the program counter Referred to as the Instruction Pointer (IP) in other microprocessors PC points to the next program instruction always Afterfetching an instruction (1 or multi byte), PC is automatically incremented to point to the next instruction

21-Jan-03

10

Registers - SP
l l

SP is the stack pointer SP points to the last used location of the stack
– –

push will first increment SP and then copy data pop will first copy data and then decrement SP

l l l l

In 8051, stack grows upwards (from low mem to high mem) andcan be in the internal RAM only On power-up, SP is at 07H Register banks 2,3,4 (08H to 1FH) is the default stack area Stack can be relocated by setting SP to the upper memory area in 30H to 7FH


mov SP, #32H
11

21-Jan-03

Registers - PSW
l l l l

Program Status Word is a “bit addressable” 8bit register that has all the flags CY - Carry Flag


Set whenever there is a carry in anarithmetic operation Carry from D3 to D4. Used for BCD operation P=1 if A has odd number of 1s Even parity Set if any arithmetic operation causes an overflow

AC - Aux. Carry Flag


P - Parity Flag
– –

l

OV - Overflow Flag


21-Jan-03

12

Flags - Illustration
l

Addition example
– –

mov A, #38 add A, #2F

38 + 2F --------67 --------CY = 0 AC = 1 P =1

0011 1000...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Microprocesadores
  • Microprocesador
  • Microprocesadores
  • MICROPROCESADOR
  • Microprocesador
  • Microprocesadores
  • Microprocesador
  • Microprocesadores

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS