JanineXD 0 Newbie Poster

I've been searching for the solution for days already but found none except this as a starting point: http://www.emu8086.com/assembler_source_code/calc.asm.html
(See how the calc.asm backspaces the digits when it exceeds to the limit)

So I needed to fix this working code (I'm using 8086 assembler btw):

TITLE "program 9"

.MODEL SMALL
.STACK 200
.DATA     

CRLF DB  0DH,0AH,'$'
m1 db 'Enter an 8 bit binary number, between 0 and 255: ','$'
m2 db 'The input is now inverted to: ','$'

.CODE      
.STARTUP 
        
    lea dx, m1    ;disp input msg
    mov ah, 09h
    int 21h     

    xor bl, bl
    mov cx, 08h
    mov ah, 1     ;stop of looping
    
    enter_in:     ;8-bit binary number input
    int 21h
    cmp al, 0dh   ;compare    
    je exit_in    ;jump if equal to zero
    and al, 0fh
    shl bl, 1     ;logical shift left
    or bl, al     
    
    cmp     AL, '0' ;compare if AL is equal to 0
    jae     accept  ;jump to "ACCEPT" if above or equal
    jmp     next    ;unconditional jump to "next"
        
    accept:        
    cmp     AL, '9' ;compare if AL is equal to 9
    jmp     accept  ;unconditional jump to "accept"
        
    next:       
    
    loop enter_in   ;this will start the input loop
    
    exit_in:        ;this will be accessed when
    mov al, bl      ; cmp al, 0dh is equal to zero
    mov cx, 08h
    
    loop_in:
    shl al, 1
    rcr bl, 1
    loop loop_in
                
    LEA DX, CRLF     ;new line before m2
    mov ah,09h
    int 21h   

    lea dx, m2 
    mov ah,09h
    int 21h
    
    mov cx,08h
    
    mov ah, 2
    
    output_in:
    shl bl, 1
    
    jnc zero_in  ;jump to zero_in if carry not set
    mov dl, 31h  ;move 1 to dl
    jmp disp_in  ;unconditional jump to disp_in
    
    zero_in:
    mov dl, 30h  ;move 0 to dl
    
    disp_in:
    int 21h
    
    loop output_in
    mov ah, 4ch     ;move L
    int 21h

ret  
       
END

To have it accept only the inputs: 1 and 0.
The program itself says that you should enter just binary, so when a user inputs:
1012
It will automatically delete 2 and you have it like this now:
101

I don't know what methods should be used. Trust me, my head is achingggggg with these assembly codes. Please guide me through because I really wanna learn.

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.