I started this macro that does the following in MASM,

1. takes the user input for character entered
2. copies character from AL to _char variable
3. converts to ascii value and outputs to console

I was able to do the first 2 having issues with the conversion process.

Here is my variables

_char BYTE ?

Here is my macro

mConvert MACRO value:REQ
	mWrite "Enter a character: "
	call readchar
	call writechar
	mov _char, al

	;I assume the conversion goes right in here based on how my macro works

	call crlf
	mWrite "The ascii value is: "
        mov al, _char
	call writechar	

;invoke macro
        mConvert _char

I assume you would like to turn the value in memory
into the asci representation of the decimal value.
For example, the value 20h (32d) in a byte
into the asci characters 33h '3' and 32h '2',
sent to the console would display '32'.
For the value 231, the following process would
be performed:
231 / 100 = 2 + 30h = 32h '2'
031 / 10 = 3 + 30h = 33h '3'
001 / 1 = 1 + 30h = 31h '1'

I know minimal in ASM and feel pretty overwhelmed with all the stuff I know so far, I hate not being able to figure something out. To be honest I have no clue what you said to me all I really saw there was math. I just want the ascii value to display, converting can happen wherever it is possible im not that picky.

I am able to call other ways to write to screen and get weird numbers like if I do call writehex I get 0001E61, well I know that 61 is the hex value for a but I don't want that other crap to come up either. If I do call writedec I get +7777 and I know that isn't even close to the decimal value of a. What can I do hear? Any suggestions...


added xor ah,ah where my comment was and removed the mov al, _char line and did call writedec and it works perfect. Thanks anyways, at least you tried the manager and Gamedev.net pretty much refused to really help me.

The characters seen on the display are represented
by asci values.
Look at a ASCII table and you will see the printable
digits and their values.
The printable digits 0 through 9 have the values
30h to 39h in hexadecimal and 48 to 57 in decimal.
When the asci value is sent to the console its associated
graphic is displayed.
So, when you recieve a byte from the keyboard to display
its value you must turn each of its digits (whatever base)
into their associated asci values.
Like, for example, to display the decimal value 32
you must print two characters to the display a '3' and a '2',
each represented by a specific ASCII value.
Thus, it will require some math to find the digits that make
up the value in memory and turn them into asci values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.