January 04, 2012
Write an assembly language program to subtract two 8 bit numbers, output 8 bit number using memory location.
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to subtract two 8 bit numbers which are stored at different memory location and output should 8 bit number and output should be store at another memory location.
Algorithm:
- Initialize memory pointer
- Move First Number into Accumulator
- Get second Number using memory location
- Now subtract first number and second number
- Store output at another memory location
Program:
Memory Address
|
Op-code
|
Operand
|
Comments
| ||||
2000
|
LXI
|
H,2050 H
|
Load first number at 2050 H
| ||||
2003
|
MOV
|
A,M
|
Move the first number into A
| ||||
2004
|
INX
|
H
|
Get Second number
| ||||
2005
|
SUB
|
M
|
Add first number and Second
| ||||
2006
|
STA
|
2052 H
|
Store output at 2052
| ||||
2009
|
RST
|
5
|
Set Break-point to execution
| ||||
200A
|
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.
MOV rd,rs: This instruction copies data from the source register into destination register.
INX: This instruction is used to increment the content of register pair by one.
SUB: This instruction is used for subtract the content of specified register from accumulator and store output in accumulator.
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.
MOV rd,rs: This instruction copies data from the source register into destination register.
INX: This instruction is used to increment the content of register pair by one.
SUB: This instruction is used for subtract the content of specified register from accumulator and store output in accumulator.
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-08
2051-05
Output: 2052-08-05=03
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: 08)
- Press ENTER and Provide your Second Input (2051 :05)
- 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)
No comments:
Post a Comment