[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1019
  • Last Modified:

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

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
ZOOMP
Asked:
ZOOMP
2 Solutions
 
dimitryCommented:
I don't understand the question. What exactly do you want to do ?
1234 (decimal) == 04D2 (hexadecimal)
11 (binary) == 3 (decimal)
0
 
BrianGEFF719Commented:
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
 
y2kswCommented:
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
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
kotkovaCommented:
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
 
kotkovaCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
How about rating it now?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Split between dimitry, mayankeagle and kotkova.
0
 
171160Commented:


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
 
Mayank SAssociate Director - Product EngineeringCommented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now