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!

Recommended Answers

All 7 Replies

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

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?

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.

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.

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

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

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...

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.