HI...

would anyone give me some ideas in converting decimal to binary...?...i have some ideas but its hard for me to implement it...i just came up with the wrong code...i'm using a86 assembly language...


.

You mean like a string say "128" into a numeric value say 128 (or 0x80, or 10000000)

If you posted your code, we might have a better idea what it is you're trying to do, and maybe even suggest a quick fix to your own work.

yup....

here is my code....its not finish yet..i have the idea but implementing it into a code is a difficult one ...

begin:
	call ask_input
	INT 20H	

ask_input:
	lea dx,msg
	mov ah,9
	int 21h

	mov ah,1
	int 21h
	mov bl, al
	int 21h

	mov cl, 30h
	sub bl, cl
	sub al, cl
	mov dl, al
	mov ax, 0
	mov al, 10
	mul bl
	add dl, al
	mov bl, dl
	call divide

divide:
	mov al, 2
	div bl
	push al



	LOOP DIVIDE
	
	
// this portion is for the try again...

END_NA:
	
        lea dx, msg1
	mov ah, 9
	int 21h
	 
	mov ah, 1 
	int 21h

	cmp al, 'y'	
	je  ask_input
                JNE BEGIN_CHECKING1

	cmp al, 'Y'
	je ask_input
	
BEGIN_CHECKING1:
	
	cmp al, 'n'
;	jne END_NA
	je END_NA_JUD

	cmp al, 'N'
;	jne END_NA
	je END_NA_JUD

END_NA_JUD:	

	mov ah, 4ch
	int 21h

msg db 0ah,0dh,"Please enter a number: $"
msg1 db 0ah,0dh,"TRY AGAIN [Y/N] : $"

divide doesn't return, and even if it did, you'd just run right into it again.

Consider something like

loop:
    call print_prompt
    call get_input
    call convert_to_integer
    call divide
    call again
    jne loop

Write each one in turn.
Post the one you get stuck on.

i've evaluated the code.. but my problem is in the divide section..its not the complete code...i dont know what code to be added on it...

loop:
	call print_prompt
	call get_input
	call convert_to_integer
	call divide	
	call again
	
print_prompt:
	mov ah,09h
	lea dx,msg
	int 21h
	ret

get_input:
	mov ah,0ah
	lea dx,store_input
	int 21h
	ret

convert_to_integer:

	mov ah,1
	int 21h
	mov bl, al
	int 21h

	mov cl, 30h
	sub bl, cl
	sub al, cl
	mov dl, al
	mov ax, 0
	mov al, 10
	mul bl
	add dl, al
	mov bl, dl
	int 21h
	ret
divide:
	mov al, 2
	div bl
	mov dl, al
	push dx
	loop divide
	cmp dl,0
	pop dx
 	
	int 21h
	ret
	
again:
	mov dx,offset msg1
	mov ah, 9        
	int 21h
	mov ah, 1   
	int 21h
	mov char1,al	
	cmp al,'y'
	je loop
	jne end
       	 cmp al,'Y'
	je loop
	jne end
	int 21h
	ret 

end:	

	mov ah, 4ch
	int 21h

msg db 0ah,0dh,"Please enter a number: $"
msg1 db 0ah,0dh,"TRY AGAIN [Y/N] : $"
char1 db ?


store_input db 3 dup()

after on the first looping of the divide...either 1 or 0 will be put in stack...but how it is to be implemented here...that is one of my problem..that i been stuck with...

If you have a 0 or 1, then you need to add decimal 48 to get a '0' or a '1' you can print.

can you do it for me..or where particularly in the code i'll place that decimal 48.?...


that 0 or 1 is serve as its remainder either of t this 2..

thanks for the help....

problem solved.....

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.