News:

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

asc() and chr() functions

Started by Jackal, March 15, 2007, 05:13:53 AM

Previous topic - Next topic

Jackal

i need help or a start on converting letters to there ascii value and also ascii value to the letter. Also i need to know if someone can explain how arrays work. I have the following array but cant seem to get it right..

constdec  dd 112, 222, 076, 186, 040, 150, 004

Tedd

Letters are stored in memory just as values - it's what you do with these values that counts. So if you decide to treat them as letters (using ASCII) then you can use them like that, but really there's no difference at all.
So.... to convert a letter to its ascii value, all you need to do is print it as a number rather than a letter -- "A" is stored as the value 65, so you get the letter (as a byte), convert the value to its decimal string, and then you cqan print that string. Equally, number->letter is just: convert decimal string to value, print value as character.
And on to arrays. Yep, that looks like an array :wink What can't you get right? It's an array of dwords, so if you want to access the first element then it's at "DWORD PTR [constdec]" and if you want to access the second it's at "DWORD PTR [constdec+4*1]", third is "DWORD PTR [constdec+4*2]" and so on... more generally, the nth element is at "DWORD PTR [constdec+4*(n-1)]" But for a byte array (create using "db" instead of "dd") then it would be "BYTE PTR [constdec+(n-1)]"
No snowflake in an avalanche feels responsible.

Jackal

hmm ok this is kinda of what i thought on both but wasnt sure. I was getting an error tring to access the array but i am pretty sure why so thanks.