can't figure out why keep getting an 'illegal operation' message or infinite loop on this ascii to binary conversion program

; when i run this code i get either an illegal operation notice or an infinite loop
.model small          

.stack 100h
count = 50          

     maxInput db count
     inputCount db ?          
     buffer db count dup(?)

input KEYBOARD <>     
start db "Enter an integer between -32,768 and 32,767: $"
continue db "Would you like to continue?(y/n) $"    

main PROC          
mov ax, @data          
mov ds, ax          

mov ah, 9          ; write a '$' terminated string to standard output
mov dx, offset start     ; load the string to be output
int 21h              

mov ah, 0Ah          ; read an array of buffered characters frm std input
mov dx, offset input     ; load the address to store the input
int 21h              

mov ah, 6          ; write a character to standard output
mov dl, 0Ah          ; output a newline
int 21h              

mov cx, 0          ; clear the counter
mov cl, input.inputCount     ; number of bytes in input string
mov si, offset input.buffer          ; point to the input string

printNumber:          ; loop used to output the input
     mov dl, byte ptr [si]     ; mov the number to be printed to 'dl'
     int 21h          
     inc si          
     loop printNumber

     mov dl, 09h     ; print a tab
     int 21h    

mov si, offset input.buffer          ; point to the input string
mov ax, 0          ; clear the accumulator
mov bx, 10          ; bx is the multiplier
mov cx, 0          ; clear the counter
mov cl, input.inputCount     ; number of bytes in input string

Convert:          ; loop used to convert ASCII input to binary
     and byte ptr [si], 00001111b     ; actual conversion
     mul bx          
     add al, byte ptr [si]    
     loop Convert    

mov cx, 16          ; count 16 bit output

binloop:          ; loop used to output binary numbers
     .IF cx == 8          ; if 8 bits have been output
          mov ah, 6     ; write a character to standard output
          mov dl, 20h     ; print 'space'
          int 21h          

     shl ax, 1          ; capture bit in carry flag
     jc put1               ; if it's a '1', go to put1
     mov dl, '0'          ; load a '0'
     int 21h              
     jmp proceed          ; go to proceed

     mov dl, '1'          ; load a '1'
     int 21h              
     loop binloop          

main ENDP          
mov ah, 4ch          
int 21h              

END main          
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

At the very least, your shl ax is going  to mess up the function code in ah.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
As grg99 said, you're using the same register as the function code in AH and the accumulator for your value. I notice you're not using SI for anything; just move the value into SI before the loop, and use that instead of AX.

Hint: Instead of the conditional jump, use ADC - Add with Carry.

mov dl,0
shl si,1    ;Will set the carry flag
adc dl,'0'  ;Adds '0' if no carry, or '1' if carry
int 21h

This way, instead of duplicating code and having two jumps (one conditional), you have three statements that get it straight in.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: grg99 {http:#12519651} & Rosuav {http:#12889515}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.