Monday, 3 October 2011

Table of 2

In this program the starting address is taken as 2001H.
The table of 2 {2,4,6,8,.......,20} would be saved in memory location starting from 2001H location.
CODE: 




               LXI H,2001H                                     ; Make H/L pair as pointer to location 2001H
               MVI A,00H                                        ;
               MVI  B,10                                          ; Taking Register B as a counter for table
LABEL: ADI 02                                               ; Add 02 as immediate value toRregister A
               MOV M,A                                         ; Save value of Register A to memory location pointed by H
               INX H                                                ; Increment the address pointed by Register H
               DCR B                                               ; Decrement the B
               JNZ LABEL                                      ; Check for ZERO  and Jump to LABEL