Jump to content
  • Advertisement
Sign in to follow this  
crucifer

32bit X86 Assembler, text ouput

This topic is 4880 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In 16 bits, when I wanted to ouput text I simply had to do this : mov dx, [msgptr] mov ah, 9 int 21h but how can I do something equivalent in a 32-bit environment ? does interupts ONLY take 16 bits parameters ?

Share this post


Link to post
Share on other sites
Advertisement
I have no idea if int21+ah=9 will use 32-bits, but you could try putting the pointer in EDX and see what happens... assuming you're in flat memory model.

What operating system are you running your final build on?

Share this post


Link to post
Share on other sites
I'm running on windows.

When I try filling the 32 bits register with 16 bits values (by padding the other 16 bits with 0), the interupt causes a program crash.

I did try ah=9(string) and ah=2(char) ... both = crash

Share this post


Link to post
Share on other sites
Third guy beat me to it. You can't do the same old interrupts tricks in 32-bit applications. If you assemble your program as a 16-bit binary (if your OS still even supports those) it will work but then you're still stuck in 16-bit mode, which while it does have its uses, doesn't do much for modern gaming.

Embrace 32-bit code. I just recently realized that my compiler is probably going to force me to write one function in assembly because it refuses to do something that it should be able to do, but oh well, that will be fun, because I love assembly and today get so little chance to write it.

Share this post


Link to post
Share on other sites
Yeah, you really should only use assembly when you have to. In the project I'm working on, the only assembly I use is to write atomic and endian-converting functions (need to have versions that work across compilers).

Share this post


Link to post
Share on other sites
Ok ... so I can't use interrupts ...

If I still want to use assembly, how can I ouput text to stdout without calling any library ? What's my alternative ?

By debugging "cout", "printf" and "putch", I saw that a special assembly instruction called "systementer" was executed to output the text to the console...

After a lot of search, I was unable to get a good description as of how to use this instruction.

Anybody has a clue ?

Share this post


Link to post
Share on other sites
You don't. stdout is a Windows console HANDLE.

sysenter is the instruction to transition to kernel mode. You do NOT use this directly, as the method of this is internal and undocumented, and changes from Windows version to version (used to use an interrupt, just changed to sysenter). It was never intended to be something 3rd party programmers could use, like INT 21h was.

Share this post


Link to post
Share on other sites
damn ... that's not the answer I was hoping for ...

But still, you saved me a lot of time at searching somewhere useless ...

Thx

Share this post


Link to post
Share on other sites
Actually you can use interrupts in 32bit mode. Perhaps not in win32 environment, but most definitely when programming for linux. When no sysenter instruction is available int can be used to do system calls. But it's true that what you're trying to do will not work on linux either. This is because int 21h is not hooked to the old DOS interrupt.

Here's an article about system calls under Windows and how they work: CodeGuru.Com

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!