February 08, 2012
Write an assembly language program to calculate the sum of series of 8-bit numbers, output 8-bit number.
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: In this program the length of series is in memory location 2300 H and series itself begins from memory location 2301 H. The result of sum is stored in memory location 2500 H.
Algorithm:
- Initialize counter as number of data
- Initialize pointer as first location of data
- Clear accumulator
- Get first data and Add the first data with accumulator
- Decrement counter
- Check counter for zero, if not zero then add next number and so on
- Store output
- End the Program
Program:
Memory Address
|
Op-code
|
Operand
|
Comments
|
2000
|
LXI
|
H,2300 H
| |
2003
|
MOV
|
C,M
|
Initialize counter
|
2004
|
MVI
|
A,00 H
|
Initialize pointer
|
2006
|
INX
|
H
|
Get first data
|
2007
|
ADD
|
M
|
Add first data to accumulator
|
2008
|
DCR
|
C
|
Decrement counter
|
2009
|
JNZ
|
2006
|
Check for counter
|
200A
|
STA
|
2500 H
|
Store output
|
200D
|
RST
|
5
| |
201B
|
END
|
End the program
|
Used Instruction:
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MVI: This instruction is used to store 8 bit data in specified register.
MOV: This instruction is used to copy the content from source register to destination register.
INX: This instruction is used to increment the content of register pair by 1.
ADD: This instruction is used to add the content of specified register to the content of accumulator and store output in accumulator.
DCR: This instruction is used decrement the content of specified register by 1.
JNZ: Jump if value of specified register is not zero.
STA: This instruction is used to store the content of accumulator at specified memory address.
RST 5: This instruction is used to set break-point for the execution.
END: This instruction is used to execute the program.
Result:
Input: 2300 H-04 H
2301 H-01 H
2302 H-02 H
2303 H-03 H
2304 H-04 H
Output: 2500-0A H
Procedure to look output
- After press ENTER, You will get first screen
- Press G and Provide Initial address (as 2000)
- Press SHIFT+4,You will get first screen again
- Press M and Provide Input location for Input (M2300)
- Press ENTER and Provide your Input at location (2300:04H)
- Press ENTER and Provide your Input at location (2301:9AH)
- Press ENTER and provide your Input at location (2302:52H) and so on…
- Press SHIFT+4
- Press G and Provide Initial address (as 2000)
- Press SHIFT+4,You will get first screen again
- Press M and Provide address for output (M2500) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
nice one i like it too much..
ReplyDelete