1. We will be in Read Only mode (no new threads, replies, registration) for several hours as we migrate the forums to upgraded software.

How to convert from decimal to binary using DEBUG(Assembly)

Discussion in 'Homework Help' started by metal10, Nov 15, 2009.

1. metal10 Thread Starter New Member

Nov 15, 2009
6
0
Hello every1, the title basically says it all, so how do i convert from decimal to binary using DEBUG (Assembly)!

org 100h
section .text
start:
mov ax, output
mov bx, [num]
sub dx, dx

I think this code is wrong, ppl plz help me!

2. metal10 Thread Starter New Member

Nov 15, 2009
6
0
come on guys, i need help!

3. Papabravo Expert

Feb 24, 2006
12,285
2,725
Wrong for what purpose? After executing three instructions does it go off into the weeds. What do you want it to do exactly?

4. metal10 Thread Starter New Member

Nov 15, 2009
6
0
i need to get it to convert from decimal to binary using DEBUG (Assemly) Program?

5. metal10 Thread Starter New Member

Nov 15, 2009
6
0
come on guys help me, i dont get the assignment and it due tomorow OMG!
I need to convert it from decimal to binary!

It says i need to prompt the user to enter an 4 digit decimal number which should sotre in null terminated string. THan if the user enter fewer than 4 digits before pressing return, then your program should ask for a 4 digit number again. Other wise it should efficiently convert the 4 character numeric string into a 16 bit numeric value and store this in a word variable. Than using a loop, convert the 16 bit value into a 16 character string of 0s and 1s. Store this in another null terminated string. Display the 16 character binary string result.

PPL PLZ HELP ME! ty if done so xD!

6. metal10 Thread Starter New Member

Nov 15, 2009
6
0
so does any1 know?

7. BMorse AAC Fanatic!

Sep 26, 2009
2,675
241
Here is what google came up with when doing a search for "Decimal to Binary Conversion in Assembly" :

Code ( (Unknown Language)):
1. ; Code written by Sanchit Karve
2. ;                   born2c0de
3. ;           printf("I'm a %XR",195936478);
4. ; Target Processor : 16-bit 80x86 Microprocessor or Higher.
5.
6. ; No User Interface code, since this is a code snippet.
7.
8. ; Code can be copied and pasted in your code since
9. ; PUSHA and POPA have been used to prevent changes to
10. ; previous Register Values.
11.
12. ; For use with 32-bit Assemblers, you can also replace
13. ; all registers with 'E' (Eg. SI becomes ESI, AX -> EAX)
14.
15.
16. ; Assumption:
17. ; Value(in decimal) to be converted in Binary should be
18. ; in register SI.
19. ; Move it from Stack or from Variable to SI register
20. ; before using this code.
21.
22.    PUSHA
23. ;  SI Contains the Value to be converted.
24.    MOV BX,80h
25.    MOV AX,BX
26.    MOV DX,SI
27.
28. loop_begin:
29.    AND DX,AX
30.    TEST DX,AX
32.    XOR DX,DX
33.    INC DX
34.
36.    PUSHA
37.
38. ;  Call Output Function or INT21h, and pass value
39. ;  stored in DX as output.
40. ;  If you're planning to pass it as an argument to a
41. ;  function, use PUSH DX to pass it via stack.
42. ;  Remember to shift the SP (or BP if you're opening
43. ;  stack frame) accordingly up the stack after the
44. ;  number has been displayed by the function.
45.
46.    POPA
47.    MOV DX,SI
48.    MOV AX,BX
49.    SHR AX,1
50.    MOV BX,AX
51.    TEST BX,BX
52.    JNZ loop_begin
53.    POPA

8. metal10 Thread Starter New Member

Nov 15, 2009
6
0
this one doesnt work, any others!

9. BMorse AAC Fanatic!

Sep 26, 2009
2,675
241

For one, what processor are you programming this for???

And explain why "this one doesn't work"....

If you can not elaborate on what you are doing and on what, then try using google to do your own homework.....