Posts

Showing posts with the label SWAP THE CONTENT

SWAP THE CONTENT

Image
GIVEN TWO DATA STORED AT MEMORY LOCATION x AND x+1. SWAP THE CONTENT OF M(x) AND M(x+1). THEORY :  In 8085 microprocessor, firstly we take two 8-bit numbers from the user and store it in different memory locations m(x) and m(x+1) respectively. Let, m(x) is 2000h and m(x+1) is 2001h. The SWAP operation will be done with the memory locations, registers, and the accumulator respectively.  ALGORITHM : Step 1: LXI H,2000h; to load the address in H-L register pair using LXI H from 16-bit location 2000h. Step 2: MOV A, M; to move the value of 2000h memory address value into the accumulator. Step 3: INX H; to increase the value of the H-L register pair to get the next memory location. Step 4: MOV B, M; to move the value of the 2001h memory location to register B. Step 5: MOV C, A; to store the value of accumulator into the C register. Step 6: MOV B, A; to store the accumulator value into the B register. Step 7: MOV B, C; to store the C regi...