?
Solved

How i can convert dex to hex ?? and bin to hex ??

Posted on 2003-03-07
13
Medium Priority
?
1,004 Views
Last Modified: 2008-01-09
mov Ax,1234

in memory Ax=04D2 ;(
how i can convert 1234 to 04D2 ??

Mov Ax,11B
in memory Ax=0003 ;(
how i can convert 11B to 0003??
0
Comment
Question by:ZOOMP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 11

Accepted Solution

by:
dimitry earned 100 total points
ID: 8091449
I don't understand the question. What exactly do you want to do ?
1234 (decimal) == 04D2 (hexadecimal)
11 (binary) == 3 (decimal)
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 8097664
test if the bits are on...if they are set that bit to on with the final number...

and BIN,00000001b ;1
and BIN,00000010b ;2
and BIN,00000100b ;4

add FINAL,00000001b ;set bit 1 to on..adding 1 to the final

....and so on
0
 
LVL 3

Expert Comment

by:y2ksw
ID: 8099179
Hex2Dec
Divide eax by 10, get edx, which contains the rest, which is the least decimal digit in BCD, add 48 ("0") and store it somewhere. Loop until eax = 0.

Dec2Hex
Multiply eax by 10. ebx = decimal value. Subtract 48 ("0"). Add ebx to eax. Loop until the source = 0.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 100 total points
ID: 8102307
Man! You already have it. If you have moved 1234 to AX, then remember - it stores 0000010011010010. Now, it depends upon you whether you interpret it as 1234 decimal or 04D2 hex - both are the same value.

If you want to print the value as 04D2, then write a routine which divides the value in AX by 16 until 0 comes. The remainders should be stored in an array. In this array, if any value is greater than or equal to 10, change it to "A" or "B" or whatever as per the value.... then, display the contents of that array in reverse order (digits converted to characters).

A similar technique helps in the other case too. Wish I could post a code for you too, but I don't have much time. Try it out yourself.

Mayank.
0
 

Expert Comment

by:kotkova
ID: 8106116
if it is simply to manipulate the values, you dont need to convert, for example:

MOV DX,0010d              (AX will contain 000Ah)
MOV BX,0005d              (BX will contain 0005h)
ADD DX,BX                 (AX will contain 000Fh)

If you need to show on screen the result of what DX contains in decimals and not hexadecimals, you need to convert the decimal value in the registry to its coresponding ASCII value.  I strongly recommend you find a
ACII table on the net: www.asciitable.com

So lets suppose you want to show on screen the decimal value in the AX registry, wicth is 15 in this example:

1) 1 decimal = 31h ASCII table and
   5 deciaml = 35h ASCII table
2) to print on screen, int 21,2 is requested -> AH must containt the value 02 (MOV AH,02) before calling int 21, and DL must containt the  ASCII character that you want to print(31 for the 1 and 35 for the 5)
3) so lets code this...:
PUSH AX            ;lets preserve the registies
PUSH BX
PUSH CX
PUSH DX

;we want to print out "15" on screen
;lets start with the "1"

MOV AH,02h          ;we will call int 21,2
MOV DL,31h          ;int 21,2 displays whats in DL
                   ;and 31 is the ASCII value of "1"      
int 21h            ;we call int 21, you see "1" on screen

; now we want to display "5" to folow the one
MOV AH,02h          
MOV DL,35h          ;35 is the ASCII value of "1"      
int 21h            ;we call int 21, you see "5" on screen

POP DX             ;we restore the registies
POP CX
POP BX
POP AX

Hope this helps, if you want to know how to convert hexa values contained in your registry to be able to print then on screen as decimals, you need to use the ASCII table, that is another set of code...let me know if that is what you want...

0
 

Expert Comment

by:kotkova
ID: 8106432
if it is simply to manipulate the values, you dont need to convert, for example:

MOV DX,0010d              (AX will contain 000Ah)
MOV BX,0005d              (BX will contain 0005h)
ADD DX,BX                 (AX will contain 000Fh)

If you need to show on screen the result of what DX contains in decimals and not hexadecimals, you need to convert the decimal value in the registry to its coresponding ASCII value.  I strongly recommend you find a
ACII table on the net: www.asciitable.com

So lets suppose you want to show on screen the decimal value in the AX registry, wicth is 15 in this example:

1) 1 decimal = 31h ASCII table and
   5 deciaml = 35h ASCII table
2) to print on screen, int 21,2 is requested -> AH must containt the value 02 (MOV AH,02) before calling int 21, and DL must containt the  ASCII character that you want to print(31 for the 1 and 35 for the 5)
3) so lets code this...:
PUSH AX            ;lets preserve the registies
PUSH BX
PUSH CX
PUSH DX

;we want to print out "15" on screen
;lets start with the "1"

MOV AH,02h          ;we will call int 21,2
MOV DL,31h          ;int 21,2 displays whats in DL
                   ;and 31 is the ASCII value of "1"      
int 21h            ;we call int 21, you see "1" on screen

; now we want to display "5" to folow the one
MOV AH,02h          
MOV DL,35h          ;35 is the ASCII value of "1"      
int 21h            ;we call int 21, you see "5" on screen

POP DX             ;we restore the registies
POP CX
POP BX
POP AX

Hope this helps, if you want to know how to convert hexa values contained in your registry to be able to print then on screen as decimals, you need to use the ASCII table, that is another set of code...let me know if that is what you want...

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8544919
How about rating it now?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10143839
Split between dimitry, mayankeagle and kotkova.
0
 

Expert Comment

by:171160
ID: 11025215


I want to know how to write a program using c++ that adds very large hexadecimals (unsigned) integers.  The two summands should be stored arrays, the summands should be stored with one digit per location in the two arrays. The program should, starting at the least significant digits compute the sum by adding the two integers digit by digit.

I have no experience in programming.

Thank you for your help
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 11025237
Please post your own question for that and we would post answers there. Don't save your question-points by disturbing already closed threads. You get those question-points only for asking your doubts, so use them.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
The Summer 2017 Scholarship Winners have been announced!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question