Hi
I am very new to assembly. I am trying to convert some numbers to binary. I have written most of the code so far, but can't figure out how to convert to binary. The user enters a number that number is stored in one register in another final register initialized to 0 the value is multiplied by 10 and the stored number is added so that if the user enters 1 the answer is one if they then enter a 2 the answer is 12, and so on. I then have to convert the final number entered to binary. That is where I am stuck. Here is what I have so far...I have been trying test, but that doesnt seem to work.
mov eax,char_prompt
call print_string ; request a char. input
call print_nl
mov edx,0
L1: ;Loop 1
call get_kb ; read input character
cmp AL, 0Dh ; compare the key entered to CR
je false2
true:
cmp AL, '0' ; compare AL to 0
jl false2 ; no match do second else
cmp Al, '9' ;compare AL to 9
jg false2 ;no match do second else
sub al,'0' ; subtract 0 from what ever is in AL
mov [input1],al ;move whatever is in AL to inputdigit
imul edx,10 ;multiply edx by 10
add edx,[input1] ;add value in input1 to value in edx
mov eax,edx ;move value in edx to eax
call print_int
call print_nl
loop L1
false2:
mov eax,out_msg3
call print_string ;jump to error statement
call print_nl
I think you may be confused.. the value in the edx register IS in binary form.
If the user entered '16' (as ascii letters from the keyboard) then after your conversion the actual value in edx is 16 (sixteen) and the (32 bit) edx register looks like this:
00000000000000000000000000010000
Do you mean that you want to re-display what the user entered but as a series of ones and zeros??