News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Dos Interupt

Started by Lupus, September 26, 2006, 12:05:52 AM

Previous topic - Next topic

Lupus

Let's say i have some code like
           
         mov dl, cl
         add dl, 64
         int 21h

Now as i understand this "int 21h" is a Dos function interupt.

Could someone clarify this for me! ie:
Assuming that the processor is an 8086 based processor, and the .asm file is made into an executable.

Does that mean, one can only run this program on a Dos based Machine?
Or will it run on any 8086 regardless of Operating system?

The reason i ask is. What happens if you wanted to program a Washing Maschine for arguments sake.



hutch--

Problem is that 16 bit DOS interrupts cannot be used in 32 bit code. very early OEM win95 allowed a few but none since. It is due to the change in how the OS accesses memory, in 16 bit DOS you had real mode access to memory, in 32 bit Windows you have protected mode with DWORD addressing range instead of the WORD size 64k range.

The contrast is real mode 16 bit code versus protected mode 32 bit and while the hardware will run either, the two do not mix as they use different addressing schemes for memory addressing.

What you do is work out the functionality you require that the DOS interrupt provided and use a system API function to provide that capacity. While DOS interrupts provided a few hundred operations, the API functions were over 12 thousand last time I looked and they are far more powerful.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Lupus

Thank You Hutch!
Just trying to walk before i run. As the book i'm using to learn, starts with Dos and only in later chapters progresses to Windows.

ChrisLeslie

Could I just clarify that the 32-bit Windows environment will emulate DOS commands and manage to execute 16-bit real mode DOS programs. Therefore, your DOS executable with int's etc will run on a Windows machine (but not on a Washing machine :dazzled:). But as Hutch has pointed out you are highly advised to actually program using Win APIs despite leaning about DOS stuff.

Chris

redskull

the INT instruction is an 8086 instruction, and will therefore operate basically the same across all x86 platforms; it's the Operating System that determines 'what to do with it', if anything, so to speak.  Basically, the interrupt number (21) is just an index into the "interrupt vector table" which is a jump-off point for function calls.  I think (but not entirely sure) that windows still internally uses interrupts for API function calls , but it's hidden beneath all the security/privilege stuff, so you don't get to worry about it.  As always, one of the guru's should jump in and clarify anything i said wrong.

alan
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Synfire

Quote from: redskull on September 26, 2006, 03:16:33 AMI think (but not entirely sure) that windows still internally uses interrupts for API function calls , but it's hidden beneath all the security/privilege stuff, so you don't get to worry about it.  As always, one of the guru's should jump in and clarify anything i said wrong.

Yea, windows internally uses the INT 2Eh interrupt, but it's generally not a good idea to use them directly. This is because between builds (not just versions!) the functions might change. This is the purpose of the API dll's, they allow your application to work no matter what Microsoft does in the background. As for security restrictions.. not so much. Playing around I've coded app's using the INT 2Eh interface before but that was just for fun. The protection/security restrictions are in regards to doing BIOS interrupts and using protected mode opcodes. For that you simply have to register with the service control manager as a device.

Regards,
Bryant Keller

Lupus

Thank's for all Your help! I had a quick look at constructing these Window thingies,
but from what i saw it looks like a nightmare. Just to put Hello World on the screen you need so much code and none of it makes sense to me : :lol

mnemonic

Lupus,

just give the WinAPI stuff a try. It is less complicated than it looks the first time.
Once you get used to it you will look back and smile.

And as for "Hello World!":
include \masm32\include\masm32rt.inc

.data
szCap db "Hello...",0
szTxt db "... World!",0

.code
start:
invoke MessageBox, NULL, addr szTxt, addr szCap, MB_OK
invoke ExitProcess, 0
end start


Doesn't really look complicateted, does it?

:wink
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Lupus

#8
No that doesn't look complicated, but what happend to all that code to produce the Window ? On my first try i had pages and pages of code just to produce the Form!

Thank's Mnemonic

japheth


> but what happend to all that code to produce the Window ?

It has been swept under the carpet. And yes, the Windows API is more complicated than it has to be ... mostly because of historical reasons, the GDI is beyond the age of 20.

PBrennick

Lupus,
Since you only need to produce a MessageBox to display the 'Hello World' message, it is not necessary to create a window.  Creating a window and all the messaging stuff can be complicated, but it is a static production which means you can re-use the code over and over again with only a few small changes.  So you create the code for a window and then save it into your own archive.  You will be adding more stuff to that archive folder and you will see that as time goes on, it gets easier and easier.  Take a look at template code.

Paul
The GeneSys Project is available from:
The Repository or My crappy website