BCD TO BINARY CONVERSION IN 8085

WRITE THIS IN THE WRITING SIDE OF THE JOURNAL

ADDRESSOPCODELABELMNEMONICSCOMMENT
400031 FF 80LXI SP,4010H;Initialize stack pointer
400321 2B 80LXI H,4000H;Pointer to the HL
400601 2C 80LXI B,4001H;set memory pointer in BC
40097EMOV A,M;move content of mem. to Acc.
400ACD 0F 80CALL BCDBIN;Subroutine to convert a BCD number to HEX
400D02STAX B;Store Acc to memory location pointed by BC
400E76HLT;8085 in Halt state
400FC5BCDBIN:PUSH B;saving B
401047MOV B,A;move content of Acc to B
4011E6 0FANI 0FH;Mask of the most significant four bits
40134FMOV C,A;move content of Acc. to C
401478MOV A,B;move content of B to Acc
4015E6 F0ANI 0F0H;Mask of the least significant four bits
40170FRRC;Rotate accumulator right 4 times
40180FRRC
4019RRC
401ARRC
401B57MOV D,A;move content of Acc. to D
401CAFXRA A;clear content of Acc.
401D1E 0AMVI E,0AH;Initialize Reg. E with 0AH
401F83SUM:ADD E;Add the contents of Reg. E to A
402015DCR D;decrement D
4021C2 1F 80JNZ SUM;jump if not zero to sum
402481ADD C;Add the contents of Reg. C to A
4025C1POP B;Restoring B
4026C9RET;Returning control to the calling program
402772HLT;8085 in halt state

) 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 WRITING SIDE OF THE JOURNAL

Scroll to Top