Sunday, April 1, 2012

Assembly language program to convert binary number to BCD using 8086 using procedures

ASSUME  CS:CODE, DS:DATA, SS:STACK1
DATA    SEGMENT
SERIES  DB 74H,29H,4AH,3BH
BCD_OUT DW 04H DUP(0H)
BCD     EQU 04H
DATA    ENDS
STACK1 SEGMENT
BALARAM DW 40H DUP(0H)
TOP_STACK LABEL WORD
STACK1 ENDS
CODE SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, STACK1
        MOV SS, AX
        LEA SI, SERIES
        LEA DI, BCD_OUT
        LEA SP, TOP_STACK
        MOV CH, BCD
        CALL BIN_BCD
        MOV AH, 4CH
        INT 21H
BIN_BCD PROC NEAR
PUSHF
PUSH AX
PUSH BX
PUSH CX
NXT_VALUE: MOV AL, [SI]
           MOV AH, 0H
           MOV CL, 64H
           DIV CL
           MOV BH, AL
           MOV AL, AH
           MOV AH, 0H
           MOV CL, 0AH
           DIV CL
           MOV CL, 04H
           ROR AL, CL
           MOV BL, AH
           ADD BL, AL
           MOV [DI], AX
           INC SI
           ADD DI, 02
           DEC CH
           JNZ NXT_VALUE
           POP CX
           POP BX
           POP AX
           POPF
           RET
           BIN_BCD ENDP
           CODE ENDS
           END START


No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...