Friday, June 17, 2011

Assembly language program for 2 digit bcd to binary conversion


; GIVEN BCD NUMBER SAY 24
; IT IS STORED AS IT IS IN MEMORY
; EVEN THOUGH IT IS STORED AS HEXADECIMAL 24
; IT IS NOT HEXADECIMAL 24 IT IS BCD 24
; NOW FOR BINARY CONVERSION
; SEPARATE 24 TO 02 AND 04
; MULTIPLY 04 BY 0A 04 TIMES THEN ADD 02 TO GET BINARY NUMBER
; THIS IS IN SHORT A DECIMAL TO HEXADECIMAL CONVERSION




; MVI B, 24H ;
; MOV A, B ;
; ANI 0FH ;
; MOV C, A ;
; MOV A, B ;
; ANI F0H ;
; RRC ;
; RRC ;
; RRC ;
; RRC ;
; MOV D, A ;
; XRA A ;
; MVI E, 0AH ;


LOOP:


; ADD E ;
; DCR D ; MULTIPLY WITH 0A REGISTER D TIMES
; JNZ LOOP ;
; ADD C ;
; STA XXXXH ;
; HLT ; END OF PROGRAM

2 comments: