8085 PROGRAMS


PROGRAMS FOR 8085 MICROPROCESSOR LEARNERS

PROGRAM 1 : Exchange the contents of memory locations


LXI H 2000H : Initialize HL register pair as a pointer to memory location 2000H.
LXI D 4000H : Initialize DE register pair as a pointer to memory location 4000H.
MOV B, M    : Get the contents of memory location 2000H into B register.
LDAX D       : Get the contents of memory location 4000H into A register.
MOV M, A    : Store the contents of A register into memory location 2000H.
MOV A, B    : Copy the contents of B register into accumulator.
STAX D       : Store the contents of A register into memory location 4000H.
HLT            : Terminate program execution.




PROGRAM 2 : 2's complement of the number

LDA 4200H  : Get the number
CMA            : Complement the number
ADI, 01 H    : Add one in the number
STA 4300H  : Store the result
HLT            : Terminate program execution




PROGRAM 3 :Calculate the sum of series of numbers

4200H = 04H
420lH = 9AH
4202H = 52H
4203H = 89H
4204H = 3EH


Result = 9AH + 52H + 89H + 3EH = 01B3H

4300H = B3H Lower byte

4301H = 01H Higher byte 



LDA 4200H

MOV C, A : Initialize counter

LXI H, 4201H : Initialize pointer

SUB A :Sum low = 0

MOV B, A : Sum high = 0

BACK: ADD M : Sum = sum + data

JNC SKIP

INR B : Add carry to MSB of SUM

SKIP: INX H : Increment pointer

DCR C : Decrement counter

JNZ BACK : Check if counter 0 repeat

STA 4300H : Store lower byte

MOV A, B

STA 4301H : Store higher byte

HLT :Terminate program execution

No comments:

Post a Comment