January 10, 2012
Write an assembly language program to add two 8 bit numbers, output more than 8 bit number using memory location
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to add two 8 bit numbers which are stored at different memory location and output should be more than 8 bit number and output should be store at another memory location. Output will be hexadecimal.
Algorithm:
- Initialize memory pointer
- Move First Number into Accumulator
- Get second Number using memory location
- Now add first number and second number
- Check for the carry
- Store the carry at memory location
- Store output at another memory location
- End the Program
Program:
Memory Address
|
Op-code
|
Operand
|
Comments
|
2000
|
LXI
|
H,2050 H
|
Load first number at 2050 H
|
2003
|
MVI
|
C,00 H
|
Initialize C for the carry
|
2005
|
MOV
|
A,M
|
Move the first number into A
|
2006
|
INX
|
H
|
Get Second number
|
2007
|
ADD
|
M
|
Add first number and Second
|
2008
|
JNC
|
200C
|
Check Carry
|
200B
|
INR
|
C
|
Increment C if there is carry
|
200C
|
STA
|
2052 H
|
Store output at 2052
|
200F
|
MOV
|
A,C
|
Store Carry in A
|
2010
|
STA
|
2053
|
Store carry at 2053
|
2013
|
RST
|
5
|
Set Break-point
|
2014
|
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.
JNC: Jump if not carry at specified memory address.
INR: It will increment the content of specified register by one.
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.
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.
JNC: Jump if not carry at specified memory address.
INR: It will increment the content of specified register by one.
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: 2050-45
2051-55
Output: 2052-9A H
2053-00 H
Input: 2050-45
2051-55
Output: 2052-9A H
2053-00 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 (M2050)
- Press ENTER and Provide your Input at location (2050: 45)
- Press ENTER and Provide your Second Input (2051 :55)
- 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 (M2052) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
What the hell man.. Where's the code ??
ReplyDelete