954,479 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to input a Char in ASM?

Hello.. I've been trying to create a simple postfix calculator..
Can anyone please tell me how I can input a char in assembly?
i tried using char as a data type but i found out that there's
no such thing as char in assembly..

Please help me.. thanks!

loveMii
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

A char in assembly is declared as db (one byte), and function 01 of int 21h (MS-DOS) returns a single character ( link here )

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

The "standard/common" lowest element is representing a standard (non-extended) character is the byte.

A byte converts to a char based on its placement in the character map/chart (ASCII if you're using ASCII).

What OS and Compiler are you using?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

I'm using a 32-bit Linux and I'm using GNU compiler..

So db is equivalent to a char? so it's as easy as that?
I'll just have to declare a variable as a db data type?

What if I wanna use ASCII? Is that possible?

Thank you for helping me.

loveMii
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

So you are using gnu c compiler? such as gcc or g++? How to do inline assembly with gnu compiler may be a little different than how it would be done in a pure assembly source file with *.asm extension. I don't know how its done with that compiler.

Don't confuse ASCII and db instruction. db declares a single byte of data, which can contain any value between 0 and 255. ascii is a character set that falls within that range. There are other character sets, but ascii is the most common for most of us. See this common ascii chart .

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

So I can't use db if I want to input a '+', '-', '*', '/' signs?

loveMii
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

of course you can.

Addsign db '+','$'


or

Addsign db 2Bh


--> 2Bh being hex value of '+' in ascii character set.

In this way:
char ascii(hex)
'-'----->2Dh
'*' ---->2Ah
'/'----->2Fh

diwakar wagle
Posting Whiz in Training
203 posts since Nov 2008
Reputation Points: 48
Solved Threads: 31
 

Is Addsign a label or is it a method or something?

Btw, thank you soo much! You've made things a lot easier for me! I really appreciate it...

loveMii
Newbie Poster
8 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: