TO FIND THE NUMBER OF ODD AND EVEN

WRITE THIS IN THE WRITING SIDE OF THE JOURNAL

ADDRESSOPCODELABELMNEMONICSCOMMENT
400021 50 40LXI H,4050H;set memory pointer in HL
4003AFXRA A;reset carry flag
400406 05MVI B,05H;move 05H to B
40060E 00MVI C,00H;set odd counter to 00H
400816 00MVI D,00H;set even counter to 00H
400A7E AGAIN: MOV A,M;move mem. to Acc.
400B1FRAR;rotate right through carry
400CD2 13 40JNC DOWN;jump if no carry to down
400F0CINR C;increment odd counter
4010C3 14 40JMP EVEN;jump to even
401314DOWN: INR D;increment even counter
401423EVEN: INX H;increment HL address
401505DCR B;decrement counter B
4016C2 0A 40JNZ AGAIN;jump if not zero to again
401921 60 40LXI H,4060H;set Hl for result
401C71MOV M,C;store odd counter no.
401D23INX H;increment HL address
401E72MOV M,D;store even counter no.
401F76hlt;8085 in halt state

Result: Draw it on the writing side

) Sign Flag is reset: Result is positive
) Zero flag is set: result is set to zero after the execution of arithmetic or logical operation
) auxiliary carry flag is set: there is a carry from bit D3 to D4
) parity flag is set: result stored in accumulator contain even number of 1’s
) carry flag is result: no carry or borrow bit during the execution of arithmetic operation

WRITE THIS IN THE BLANK SIDE OF THE JOURNAL

You cannot copy content of this page

Scroll to Top