Displaying a character's ascii in assembly? (pep8)

Slipperz's Avatar, Join Date: Aug 2012
Newbie Member

I'm using Pep8 which is a simulator for my assembly class. For the 1st step of the project I need to find a way to display a character's ascii number.
'h' is 104
deco 'h',i (decimal output 'h' immediately) will output 104.. but note that I need to manually enter 'h'.. How to I input it through like chari or on the console... if you see what i mean ...help

When I enter:
chari ascii,d ; Character input and store it in the "variable" ascii
deco ascii,d ; Decimal output of the "variable" ascii
ascii : .block 2 ;

I get 26624 instead of 104!! My teacher said it's 104 times 256 = 26624.. but why times 256.. I need to do something but I don't know what!!

sgermain's Avatar, Join Date: Mar 2014
Newbie Member
The problem is that you're trying to output the decimal value of a byte. CHARI stores a byte value, not a decimal value. You'll have to transition it over to a decimal value by loading a byte value from memory into the accumulator and then store that decimal value back into your variable.

Here's how you do that:

CHARI ascii, d
LDBYTEA ascii, d
STA ascii, d
DECO ascii, d
ascii: .BLOCK 2

That should return 104 when you enter 'h'.