Transfer ten data, which has bit D5 and D0, 0 and 1 respectively from 6430H to 6440H, else store 00 instead of transformation. (8085)
- Code:
SOLUTION:
LXI H,6430H ;source address
LXI D,6440H ;destination address
MOV C,0AH ;counter
Re: MOV A,M ;gets data
MOV B,00 ;initialize B with 00
RRC ;sends D0 bit to CY
RLC ;restore original data, CY flag still holds D0 bit
JNC skip ;skips if CY(i.e. D0 bit) is 0
ANA 20H ;ANDs D5 bit with 1 and other bits with 0
JNZ skip ;skips if not zero(i.e. D5 bit is 1)
MOV B,M ;if not skipped, stores the original data in B
Skip: MOV A,B ;moves content of B(may be 00 or original data) in A
STAX D;stores content of A in memory location hold by DE reg. pair
INX H ;increases HL reg. pair
INX D ;increases DE reg. pair
DCR C ;decreases counter
JNZ re ;repeats the process ten times
HLT ;terminates the program