8051 Assembly code to generate look up table for even numbers

Hello guys, Lets see how to generate look up table for even numbers.
     
            There are three addressing modes in 8051 micro-controller: Immediate addressing mode, Direct addressing mode and indirect addressing mode. We use indirect addressing mode in this program to generate look up table for even numbers.
Note: When we do division operation in 8051 accumulator register A holds quotient and accumulator register B holds the reminder.

 ALGORITHM:

  1. Start
  2. Initialize a register with base address of memory location where look up table needs to generated
  3. Initialize counter register with number of elements in look up table
  4. Initialize natural number register (Rd) with 01h
  5. Move 02h to accumulator register B
  6. Move value in Rd to accumulator register A
  7. Divide A by B and check if value in B is 0
    • If value in B is 0 then store the value in Rd to memory location, increment Rd and address register and jump to step 5
    • Else increment Rd and jump to step 5
  8. Repeat steps 5-7 until counter register becomes zero
  9. Stop

Here is example code for look up table of first 10 even numbers stored in internal memory location with starting address 0xA0

 CODE:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger