8085 Assembly Language Programs & Explanations1. Statement
: Store the data byte 32H into memory location 4000H.
Program 1:
MVI A, 32H : Store 32H in the accumulator
STA 4000H : Copy accumulator contents at address 4000H HLT : Terminate program execution
Program 2:
PROGRAM TO LOAD A WITH 30H ,B WITH 44H ,H WITH 93H.
ANS:
ALOGRITHM:
STEP 1: LOAD A WITH 30H
STEP 2: LOAD B WITH 44H
STEP 3:LOAD H WITH 93H
STEP 4: STOP
MVI A, 30H ; (LOAD A WITH 30H)
MVI B,44H ; (LOAD B WITH 44H)
MVI H,93H ;(lOAD H WITH 93H)
HLT ;
Program 3:
LOAD B AND C WITH DATA BYTES 65H AND 87H . ADD B WITH C, AND STORE RESULT IN B.
ANS:
ALGORITHM:
STEP 1: LOAD B REG. WITH 65H
STEP 2: LOAD C REG. WITH 87H
STEP 3: LOAD ACCUMULATOR WITH B REG.
STEP 4:ADD A REG WITH B REG.
STEP 5: STORE RESULT IN B REGISTER.
STEP 6: STOP.
PROGRAM :
MVI B, 65H ; LOAD B REG. WITH 65H
MVI C, 87H ; LOAD C REG. WITH 87H
MOV A, B ; LOAD A REG. WITH B REG.
ADD C ; A REG <---A REG.+ B REG.
MOV B, A ; STORE RESULT IN B REG.
HLT ; STOP
Program 4:
ADD THE CONTENTS OF TWO MEMORY LOCATIONS D000H AND D0001H. STORE RESULT IN MEMORY LOCATION D002H.
ALGORITHM :
STEP 1: LOAD FIRST NUMBER FROM MEMORY LOCATION D000H.
STEP 2:LOAD SECOND NUMBER FROM MEMORY LOCATION D001H.
STEP 3:ADD FIRST NUMBER WITH SECOND NUMBERS.
STEP 4: STORE RESULT TO MEMORY LOCATION D002H.
STEP 5: STOP.
PROGRAM :
LDA D000H ; LOAD FIRST NUMBER FROM D000H IN A REG.
MOV B, A ; COPY IT TO B REG.
LDA D001H ; LOAD SECOND NUMBER FROM D001H IN
ADD B ; LOAD A REG.<---A REG. + B REG.
STA D002H; STORE RESULT AT MEMORY LOCATION D002H
HLT ;
write a program addition of two 16-bit numbers:
Program - 5.a: Add two 16-bit numbers - Source Program 1
Sample problem:
(4000H) = 15H
(4001H) = 1CH
(4002H) = B7H
(4003H) = 5AH
Result = 1C15 + 5AB7H = 76CCH
(4004H) = CCH
(4005H) = 76H
Source Program 1:
LHLD 4000H : Get first I6-bit number in HL
XCHG : Save first I6-bit number in DE
LHLD 4002H : Get second I6-bit number in HL
MOV A, E : Get lower byte of the first number
ADD L : Add lower byte of the second number
MOV L, A : Store result in L register
MOV A, D : Get higher byte of the first number
ADC H : Add higher byte of the second number with CARRY
MOV H, A : Store result in H register
SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H.
HLT : Terminate program execution
No comments:
Post a Comment