Facebook
From Sudipto Rudro, 1 Month ago, written in x86 Assembler.
This paste is a reply to Re: Untitled from Sudipto Rudro - go back
Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
INCLUDE 'EMU8086.INC'
.MODEL SMALL
.STACK 100H
.DATA

.CODE

MAIN PROC
    MOV BX,0
    MOV CL,4
    ;PRINT"ENTER THE HEX NUM "
    MOV AH,1

FOR1:
    INT 21H
    CMP AL,0DH
    JE END_FOR
.model small
.stack 100h
.data
msg db 'Enter the data in binary format  $'
msg1 db 0dh,0ah,'output in binary form is : $'
.code
main proc
    mov ax,@data
    mov ds,ax
    mov ah,09h
    lea dx,msg
    int 21h
    
    CMP AL,41H
    JGE LETTER
mov bx,0   
    mov cx,16
    
    ;DIGIT
    SUB AL,48
    JMP SHIFT
again:  
    
LETTER:
    SUB AL,37H
    mov ah,01h 
    int 21h
    cmp al,13  
    je printout 
   
    and al,0fh
    shl bx,1     
    or bl,al    
    loop again
    
SHIFT:
    SHL BX,CL ;NEW SPACE TO STORE
    OR BL,AL
    JMP FOR1
    printout:
    mov ah,09h
    lea dx,msg1
    int 21h
          
    mov cx,16     
    disp:
    
END_FOR:
    shl bx,1
    
    PRINTN
jnc again1
    
    ;XOR CH,CH
    MOV CX,4
    MOV AH,2
mov dl,49
    mov ah,02h
    int 21h
    jmp display
    
FOR2:
    MOV DL,BH
    SHR DL,4
    SHL BX,4
    again1:
    mov dl,48
    mov ah,02h
    int 21h 
    
    CMP DL,10
    JGE LETTER2
display:
    loop disp  
    
    ;DIGIT
    ADD DL,48
    INT 21H
    JMP END_OF_LOOP2
    
LETTER2:
    ADD DL,55
    INT 21H
    
END_OF_LOOP2:
    LOOP FOR2
    
    MOV AH,4CH
    INT 21H

MAIN ENDP
END MAIN 
mov ah,4ch
    int 21h
    main endp
end main