hex to decimal printing issue?

Question!

my actual problem is that the print is not working out with me i don't know the reason and this is my code:

; multi-segment executable file template.

data segment
    ; add your data here!
    M1 db "Enter a number from below for the convarting you want to make.. ",0ah,0dh,"1 - Hex to Decimal & Binary ",0ah,0dh,"2 - Decimal to Hex & Binary",0ah,0dh,"3 - Binary to Hex & Decimal",0ah,0dh,"$",0ah,0dh 
    V  db 0ah,0dh,"Enter the digits you want to convert",0ah,0dh,"$",0ah,0dh
    E  db 0ah,0dh,"You have entered a wrong hex digit/s",0ah,0dh,"$"
    S  db 0ah,0dh,"$"                                                
    Bu dw 0 
    Bu1 dw 0
    Bu2 dw 0
    Bu3 dw 0
    cdec dw 0
    result dw '00000', 0 
    result1 dw '0000000000000000',0
    data1 dw 0


ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax

    ; add your code here

    lea dx, M1
    mov ah, 9
    int 21h        ; output string at ds:dx

    ; wait for any key....    
    mov ah, 1
    int 21h 

    CMP al,'1'
    JE C1
    CMP al,'2'
    ;JE C2  
    CMP al,'3'
    ;JE C3

    jmp start

    C1:  lea dx, V
         mov ah, 9
         int 21h

        pusha

        mov cx,4
        mov ah,1

        Enter: int 21h
        xor bx,bx
        mov bl,al
        push bx

        loop Enter

        pop bx

        jmp check 


     h: mov Bu,bx

        pop bx 

        jmp check1 

     h1: mov ax,16
         mul bx
         mov Bu1,ax


        pop bx 

        jmp check2 

     h2: mov ax,256
         mul bx
         mov Bu2,ax


        pop bx 

        jmp check3

     h3: mov ax,4096
         mul bx

         mov Bu3,ax


         xor dx,dx
         xor ax,ax

         add dx,Bu

         add dx,Bu1

         add dx,Bu2

         add dx,Bu3

         mov cdec,dx

         lea dx,S
         mov ah,9
         int 21h 

           popa 

         jmp decimal       

            check:

        cmp bx,"0"
        je  De
        cmp bx,"1"
        je  De
        cmp bx,"2"
        je  De
        cmp bx,"3"
        je  De
        cmp bx,"4"
        je  De
        cmp bx,"5"
        je  De
        cmp bx,"6"
        je  De
        cmp bx,"7"
        je  De
        cmp bx,"8"
        je  De
        cmp bx,"9"
        je  De

        or bx, 0000000000100000b

        cmp bx,"a"
        je AA

        cmp bx,"b"
        je AA

        cmp bx,"c"
        je AA

        cmp bx,"d"
        je AA

        cmp bx,"e"
        je AA

        cmp bx,"f"
        je AA

        jmp error


  AA: sub bx,57h      

   jmp h

  De: sub bx,30h

   jmp h


            check1:  
        cmp bx,"0"
        je  De1
        cmp bx,"1"
        je  De1
        cmp bx,"2"
        je  De1
        cmp bx,"3"
        je  De1
        cmp bx,"4"
        je  De1
        cmp bx,"5"
        je  De1
        cmp bx,"6"
        je  De1
        cmp bx,"7"
        je  De1
        cmp bx,"8"
        je  De1
        cmp bx,"9"
        je  De1

        or bx, 0000000000100000b

        cmp bx,"a"
        je AA1

        cmp bx,"b"
        je AA1

        cmp bx,"c"
        je AA1

        cmp bx,"d"
        je AA1

        cmp bx,"e"
        je AA1

        cmp bx,"f"
        je AA1

        jmp error


  AA1: sub bx,57h      

   jmp h1

  De1: sub bx,30h

   jmp h1      
        jmp error



              check2:  
        cmp bx,"0"
        je  De2
        cmp bx,"1"
        je  De2
        cmp bx,"2"
        je  De2
        cmp bx,"3"
        je  De2
        cmp bx,"4"
        je  De2
        cmp bx,"5"
        je  De2
        cmp bx,"6"
        je  De2
        cmp bx,"7"
        je  De2
        cmp bx,"8"
        je  De2
        cmp bx,"9"
        je  De2

        or bx, 0000000000100000b

        cmp bx,"a"
        je AA2

        cmp bx,"b"
        je AA2

        cmp bx,"c"
        je AA2

        cmp bx,"d"
        je AA2

        cmp bx,"e"
        je AA2

        cmp bx,"f"
        je AA2

        jmp error


  AA2: sub bx,57h      

   jmp h2

  De2: sub bx,30h

   jmp h2


               check3:  
        cmp bx,"0"
        je  De3
        cmp bx,"1"
        je  De3
        cmp bx,"2"
        je  De3
        cmp bx,"3"
        je  De3
        cmp bx,"4"
        je  De3
        cmp bx,"5"
        je  De3
        cmp bx,"6"
        je  De3
        cmp bx,"7"
        je  De3
        cmp bx,"8"
        je  De3
        cmp bx,"9"
        je  De3

        or bx, 0000000000100000b

        cmp bx,"a"
        je AA3

        cmp bx,"b"
        je AA3

        cmp bx,"c"
        je AA3

        cmp bx,"d"
        je AA3

        cmp bx,"e"
        je AA3

        cmp bx,"f"
        je AA3

        jmp error


  AA3: sub bx,57h      

   jmp h3

  De3: sub bx,30h

   jmp h3 

decimal:   

    mov di,5

  con1:

cmp cdec,0
jz print 


mov ax, cdec
mov bx,10
cwd
idiv bx  
mov result[di],dx
add result1[di], 30h

xor dx,dx
mov cdec,ax

dec di   
jmp con1


print:

mov cx,5  

mov di,0

next:

lea dx,result[di]

mov ah,9
int 21h

inc di 
loop next

 mov dl,'h'
         mov ah,2
         int 21h

         jmp Cb1

Cb1:

xor ax,ax

mov di,5

mov ax,result[di]

add data1,ax

xor ax,ax

mov di,4

mov ax,result[di]
mov bx,10
mul bx

add data1,ax

xor ax,ax

mov di,3

mov ax,result[di]
mov bx,100
mul bx

add data1,ax

xor ax,ax

mov di,2

mov ax,result[di]
mov bx,1000
mul bx

add data1,ax

xor ax,ax

mov di,1

mov ax,result[di]
mov bx,10000
mul bx

add data1,ax   

mov cx,16

mov ax,data1

mov di,
m:

cmp data1, 0
je stop

mov ax, data1
mov bl, 2
div bl  
mov result1[di], ah
add result1[di], 30h  

xor ah, ah
mov data1, ax

dec di   
jmp m 

stop:

mov bx, w.temp
mov cx, 16
print: mov ah, 2    
       mov dl, '0'
       test bx, 1000000000000000b  
       jz zero
       mov dl, '1'
zero:  int 21h
       shl bx, 1
loo print



  e error: lea dx, E
         mov ah, 9
         int 21h

         jmp C1

    exit:


    mov ax, 4c00h ; exit to operating system.
    int 21h    
ends

end start ; set entry point and stop the assembler.


Answers

Oh, the code is very hard to read, because it is not very short and some parts are not real formatted for to show here. So i do not like to read the full listing.

But i have written some little DOS application for to convert the values. (The comments inside and behind the instructions are written in the german language. But the routines are small and divided into some parts.)

http://www.alice-dsl.net/freecracmaps/Tool/Zahlswap.zip
The zip-archiv included the sourcecode and also the executable of:
DEZ2BIT.ASM
DEZ2HEX.ASM
HEX2BIT.ASM
HEX2DEZ.ASM

The values for to convert have to be added behind the name of the executable as a parameter.
Example: HEX2DEZ.exe Hexadecimal value from 0 to FFFFFFFF (max. 32 bit).



This video can help you solving your question :)
By: admin