ASM coding for addressing mode, Lecture notes of Engineering

8051 microprocessor and microcontroller

Typology: Lecture notes

2016/2017

Uploaded on 12/16/2017

ling-yun
ling-yun 🇲🇾

1 document

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The 8051 microprocessor/microcontroller
64/1
Addressing Modes
8051
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download ASM coding for addressing mode and more Lecture notes Engineering in PDF only on Docsity!

Addressing Modes

Assembly Language

• computer language between machine

language and high-level language.

  • General format.
  • [label:] mnemonic [operand] [, operand] […] [; comment]
  • START: MOV A,#0FF ;’START” IS A LABEL.

Mnemonic.field

• mnemonic instruction : ADD, MOV, DIV

• assembler directives: ORG, EQU, DB

operand field.

• contain the address or data used by the

instruction.

• Operand field dependent on the operation.

Some operation have no operand.

Special Assembler Symbol

• For the register-specific addressing

modes. - A, R0, DPTR, PC, & C

SET C

INC DPTR

• Dollar sign ($) – to refer to current value of

the location counter.

JNB TI,$ ;can also be written as HERE: JNB TI,HERE

8051 DATA ADDRESSING MODES

• assembly language instructions

  • consist of an operation mnemonic and between zero and three operands separated by commas.
  • Where two operand instructions occur, the destination is specified first, followed by the source operand.

• opcode dest_operand source_operand

Addressing Modes

• The first three modes provide access to

the internal RAM and hardware register

space.

  • thus can occur in both the source and destination operand fields.

Immediate Addressing

  • Data in the operand field.
  • Data are preceded with # prefix.
    • The immediate value is a maximum of 8-bits.
    • All bits in the high-byte must be the same (00H or FFH) - MOV A,#0FEH
    • One exception, when dealing with the DPTR register it can be 16-bits. - MOV DPTR, #2000H ; Load the value 2000H into the DPTR register

Direct Addressing

  • can access any on-chip variable or hardware

register.

  • Memory address (00H to 7FH)
  • SFR address (80H to 0FFH)
  • Predefined symbol may be used for SFR address

• MOV A,30H

  • MOV A, SBUF ; same as MOV A,99H
    • the value to be stored in memory is obtained by directly retrieving it from another memory location

All I/O ports and special function registers are assigned addresses between 80H and 0FFH.

External Direct

• MOVX A,@DPTR : read

• MOVX @DPTR,A : write

– it is used to access external memory

– only two commands, utilize DPTR.

– DPTR is loaded with the address of external

memory that you wish to read or write.

External Indirect

• MOVX @R0,A

– used in small projects with very small amount

of external RAM

– value of @R0 can only be 00h through FFh

thus limited to 256 bytes of External RAM.

Bit Address

• Accessing bit-addressable location

– Data memory (00H to 7FH)

– SFR’s (80H to 0FFH)

  • Ways to specify
    • Explicitly giving the address
      • SETB OE7H
    • Using the dot operator between byte address and bit position
      • SETB ACC.
    • Using predefined assembler symbol.
      • JNB SBUF,$

Code Address

• Give in the form of a label

• Used in the operand field for the jump

instructions.

HERE: *

SJMP HERE