Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   Displaying a character's ascii in assembly? (pep8) (http://www.go4expert.com/forums/displaying-characters-ascii-assembly-t28963/)

Slipperz 29Aug2012 18:28

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

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 14Mar2014 22:41

Re: Displaying a character's ascii in assembly? (pep8)
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'.

All times are GMT +5.5. The time now is 13:31.