April 02, 2012
Write a program to search a byte into a given series.
Apparatus Used: Microprocessor kit, Keyboards
Assumption: Search the given byte of 05 numbers stored in the consecutive memory location and stored the address of memory location in the memory location 2100 and 2301. Assume byte is in the C register and starting address of the list is 2100 H. If byte is not found store 00 at 2100 and 2301 H.
Algorithm:
- Initialize memory pointer
- Set the counter as number of byte.
- Search for the byte, if byte is found then store memory address.
- If byte is not found then increment pointer as well as decrement counter.
- Check the value of counter, if it is zero then end process else repeat the process.
- Store 00 as the result
- End the program
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
MVI
|
B, 05 H
|
Set the counter
|
2002
|
LXI
|
H, 2100 H
|
Initialize memory pointer
|
2005
|
MOV
|
A,M
|
Move data in accumulator
|
2006
|
CMP
|
C
|
Compare with given byte
|
2007
|
JZ
|
2018
|
Jump at location if byte found
|
200A
|
INX
|
H
|
Increase the pointer
|
200B
|
DCR
|
B
|
Decrement the counter by 1
|
200C
|
JNZ
|
2005
|
Repeat until counter is zero
|
200F
|
LXI
|
H,0000 H
| |
2012
|
SHLD
|
2300 H
|
Store 00 at 2300 H and 2301 H
|
2015
|
JMP
|
201C
| |
2018
|
SHLD
|
2300 H
|
Store memory address
|
201B
|
RST
|
5
|
Set Breakpoint
|
201C
|
END
|
End the program
|
Description of used instruction:
MVI: This instruction is used to store 8 bit data in specified register.
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
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 specified register pair by one.
DCR: This instruction is used decrement the content of specified register by 1.
JNZ: If result is not zero it will jump to the target address.
JZ: If result is zero it will jump to the target address.
JMP: Jump unconditionally at target address.
CMP: Compare data in memory/Register with accumulator
SHLD: The contents of register L are stored in the memory location specified by the 16-bit address in the operand and the contents of register H are stored in the next memory location.
RST 5: This instruction is used to set breakpoint for the execution.
END: This instruction is used to execute the program.
MVI: This instruction is used to store 8 bit data in specified register.
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
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 specified register pair by one.
DCR: This instruction is used decrement the content of specified register by 1.
JNZ: If result is not zero it will jump to the target address.
JZ: If result is zero it will jump to the target address.
JMP: Jump unconditionally at target address.
CMP: Compare data in memory/Register with accumulator
SHLD: The contents of register L are stored in the memory location specified by the 16-bit address in the operand and the contents of register H are stored in the next memory location.
RST 5: This instruction is used to set breakpoint for the execution.
END: This instruction is used to execute the program.
Result:
Input: 2100-10, 2101-01, 2102-03, 2103-04, 2104-08
Output: 2300
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 (M2100)
- Press ENTER and Provide your Input at location (2100:10)
- Press ENTER and Provide your Input at location (2101:01)
- 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 (M2300) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment