How do we output value in register AX?

Recommended Answers

All 12 Replies

>How do we output value in register AX?

How can you be so sure that your computer has a register?
C++, or any compiler doesn't know about registers. C++ also runs on those computer which doesn't have registers.
So, don't go at much lower level with a language as C++.

Your mother board has a processor! So definitely they should have registers. And I am pretty sure of the registers part, because I just wrote some assembly instructions and executed them...in vc++ 6.0

asm {
//your asm code goes here.
}

Your mother board has a processor! So definitely they should have registers. And I am pretty sure of the registers part, because I just wrote some assembly instructions and executed them...in vc++ 6.0

asm {
//your asm code goes here.
}

Remember these three interesting facts:
1. Some processors have no programmed registers.
2. Some processors have no AX register.
3. No standard C++ built-in assembler, so OP without CPU family and compiler name/version is ill-formed.
;)

So if you've got say 0x41 in AX, what do you expect to see as "output", and where do you expect to see it?

As the letter 'A'
As the decimal 65
As the hexadecimal 0x41
As a particular colour of pixel somewhere on screen.
As a particular audio tone through your speaker
As ......

Post the rest of your asm.

Why are you writing in ASM anyway, if you're using a win32 compiler. There isn't a lot that you can do which "has" to be asm.

Some addition:

unsigned short uax;
...
__asm mov uax,ax
...

What else? Previously executed compiled code intensively used ax register so it's absolutely useless info...

Remember these three interesting facts:
1. Some processors have no programmed registers.
2. Some processors have no AX register.
3. No standard C++ built-in assembler, so OP without CPU family and compiler name/version is ill-formed.

Hmm, I haven't come across processors that have no programmed registers. Perhaps instead of AX they probably have some other convention. For me it does not make sense if processors don't have these...just a thought tho, But I am not refuting your claim. There must be something to store data, execute low-level instructions. I guess you can refer this info in a manual. It is my belief that all intel family (8086+) have such registers...

Why are you writing in ASM anyway, if you're using a win32 compiler. There isn't a lot that you can do which "has" to be asm.

I am sort of in a pre-reverse-engineering phase of reverse engineering. I haven't started reverse engineering yet. So its kind of imperative that I understand asm. I tried using an interrupt, it always throws an exception at that point where the interrupt is called. So from that exercise I understand interrupts don't work.

So if you've got say 0x41 in AX, what do you expect to see as "output", and where do you expect to see it?

not sure. However, I know it has the value of 2 (decimal). So whatever the output I must be able to understand it is '2'...

Ok I would like say this:
C++ is not the language which runs on MiniComputers ( IBM PC). It can run on your digital wrist watch too (provided if the wrist watch has that capability). So the language doesn't guarantees the existences of registers.

So the language doesn't guarantees the existences of registers.

I don't know why u think I gave u tht idea. It is something which comes with your processor. I guess a compiler is designed for a specific processor architecture.

Listen, I am using a compiler which runs C++ on my mobile phone. My mobile phone is 1990s build and does not have registers. It just have Memory.
I am not arguing whether your PC has a register or not. Of course it has. we both knows. But the point here is that C++ language does not have any scope of registers as ASM has.
In any machine language (or assembly language), you deal directly with memory and registers. While, C,C++ are languages which are implemented at a higher level. Compliers actually hide you all the details of the hardware architecture.
If you then too want to know the value of register, I am sure your OS would have some system call to help you get those:http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx

To OP: read about a machine architecture without registers and assembler level programming:
http://en.wikipedia.org/wiki/Burroughs_large_systems
Pay attention to:

No programmer accessible registers

There were other branches in the Burroughs-like systems family tree...

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.