News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

hex values

Started by ozzy_85, April 29, 2006, 10:16:49 AM

Previous topic - Next topic

ozzy_85

all strings are stored in memory in hex values right??? wats the difference between hex values and ascii values??? how do i find the hexvalues for the string "masmforum"

thanx in advance

ramguru

Hi, Ozzy
Save your word(s) in text-file, open it with hex-editor/viewer

asmfan

Ozzy, the question is what 'string' is? Everything: code, data, etc. is stored as sequence of 0 and 1 (in a appropriate sequence of course). Bit can hold these values 0 and/or 1. 8bits are considered as byte, 16 as word, etc. What is string? A sequence of byte values(8bit) followed by 1byte zero if it's ANSI string or word values(16bit) followed by 1word zero if Unicode(windows strings)
Printable symbols are subset of all that byte/word can hold.
Russia is a weird place

asmfan

And HEX values are only representation of sequence of bits (0 and 1) such as decimal or octal or native to processor-binary.
Russia is a weird place

ozzy_85

asmfan,

by a string i meant a group of characters ending with a '\0'.

anything that is stored in memory is stored in 1's and 0's.

i want to know wether the given statement is true or false...

"a string is converted into it's ascii equivalent before it is stored in memory"

is there any difference between the ascii equivalent and hexadecimal (apart from the radix of the number system)

thnx in advance :U

MichaelW

ozzy_85,

As asmfan stated, strings, like everything else stored in memory, are stored as binary values. Hex and ASCII, as well as decimal, octal, and binary (strings of "0" and "1") are just representations of the binary values. If "ascii equivalent" means a sequence of byte values, then I would say that the statement is true.

To get the hex values, in addition to the method that ramguru suggested:

You could look the values up in a table of ASCII codes that specified the character code values in hex (most tables specify the values in decimal).

You could start the DOS DEBUG program that is supplied with Windows, and enter the following two lines at the prompt (the Enter command (e) enters the specified string into memory starting at address 0, the Dump command (d) displays a hex-ascii dump of the memory starting at address 0):

e 0 'masmforum'
d 0

Or you could code a small program that used the MASM32 HexDump procedure.
eschew obfuscation

ramguru

Quote from: ozzy_85 on April 29, 2006, 11:49:24 AM
"a string is converted into it's ascii equivalent before it is stored in memory"
I personally don't like your statement...and I'll try to prove why

First of all you have a pile of bits in a particular memory location.
Then you decide to call it A String (you had a freedom to call it A Byte, Word, Float whatever). Your choise is made...
The only thing you do next is to find a way to make it visible.
So you use API that does that job, meaning converts your pile of bits into a visible result (bytes 2 ASCII).
Actually look-up table is my preferred word than conversion...

So this is a reverse process.

Mark Jones

Quote from: ozzy_85 on April 29, 2006, 11:49:24 AM
"a string is converted into it's ascii equivalent before it is stored in memory"

I don't like this wording either. There is no "conversion" happening here - the ASCII digit "0" == 30h == 48d == 60o == 110000b. All you need to do Ozzy is look at an ASCII table, that should explain everything. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

PBrennick

Ramguru and Mark,
That pretty much sums it up, IMO, also.  Not much more to say, is there.  Once you have the data you can choose any number of ways to represent it so that you can manipulate it in the manner of your choosing.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

ozzy_85

Quote from: ramguru on April 29, 2006, 12:43:17 PM
I personally don't like your statement...and I'll try to prove why



ok thanks for clearing that up... i took a second look at the statement after i read ur post and i didn't like it either...