0

Can you please tell me why is the subroutine getting executed twice, and how can I fix it?

I have put the code below for reference , while executing I found that the the subroutine BCD_TO_BIN is being executed twice. I don't know why is this happening, can you please tell me what's wrong with this and how to avoid the same happening in the future.

org 100h

.DATA
    BCD_INPUT DB 16H 
    BIN_VALUE DB ?   

.CODE
.STARTUP
         
MOV SI, OFFSET BCD_INPUT
MOV DI, OFFSET BIN_VALUE                          
CALL BCD_TO_BIN                

BCD_TO_BIN PROC NEAR
    PUSHF
    PUSH BX
    PUSH CX
              
    MOV AL, [SI]
    MOV BL, AL      
    AND BL, 0FH
    AND AL, 0F0H
    
    MOV CL, 04H
    ROR AL, CL
             
    MOV BH, 0AH         
    MUL BH
    
    ADD AL, BL
    
    MOV [DI], AL  
         
    POP CX
    POP BX
    POPF 
    RET
BCD_TO_BIN ENDP
.EXIT
END

0 Answers0