Not Yet Answered # Conversion from Ascii to Hex in ibm pc assembely

Evenbit 52 Discussion Starter abee I am wondering if there would be any chance that someone could help me out with this, I am trying to teach myself c++ which i find it really interesting and I came accross this and would love to see how it works so i could do it and learn ...

0

hi all ,...

iam making a simple disk editor , and i need a methode that

convert from ascii to Hex representation

thank u all

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 ($30) thru 57 ($39).

If you want lower case, then 'a' thru 'f' are 97 ($61) thru 102 ($66).

If you want upper, then 'A' thru 'F' are 65 ($41) thru 70 ($46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 ($30) to it, then check to see if it is larger than 57 ($39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

0

hi Nathan..

thank u for ur kind replay , and although i figured it out and completed my disk editor program , i want to thank u for ur interest.

and i hope we can meet agian in other arguments.

thank u

abee

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 ($30) thru 57 ($39).

If you want lower case, then 'a' thru 'f' are 97 ($61) thru 102 ($66).

If you want upper, then 'A' thru 'F' are 65 ($41) thru 70 ($46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 ($30) to it, then check to see if it is larger than 57 ($39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi!

I have two tables, I will call them first-half and second-half (of the year)

```
Table: first
id jan feb mar apr
-----------------------
2 80 90 70 60
3 50 40 60 30
Table: second
id jan feb mar apr
-----------------------
2 50 70 60 90
3 80 60 50 ...
```

```
from turtle import *
import random
def allTriMedian (w=300):
speed (0)
vertices = []
point = turtle.Point(x,y)
for i in range (3):
x = random.randint(0,300)
y = random.randint(0,300)
vertices.append(trutle.Point(x,y))
point = turtle.Point(x,y)
triangle = turtle.Polygon(vertices)
a = triangle.side()
b = triangle.side()
c = triangle.side()
m1 = tirangle.median
m2 = triangle.median ...
```