Monday, July 9, 2018

 ; x8086 alp to convert a BCD into its BINARY equivalent
DATA_SEG SEGMENT
    BCD DB 25H                  ; STORAGE FOR A BCD VALUE
    BIN DB ?                    ; STORAGE FOR BINARY VALUE
DATA_SEG ENDS

CODE_SEG SEGMENT
    ASSUME CS:CODE_SEG,DS:DATA_SEG
    START:
    MOV AX,DATA_SEG
    MOV DS,AX
   
    MOV AH,BCD    
    MOV BH,AH
    AND BH,0FH
    AND AH,0F0H
    ROR AH,04
    MOV CL,10
    MOV AL,AH
    AND AX,00FFH
    MUL CL
    ADD AL,BH
    MOV BIN,AL 
    MOV AH,04CH
    INT 21H
    CODE_SEG ENDS
END START

output, variable BIN gets binary value 00011001 = 25 in decimals.

No comments:

Post a Comment

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows