Author Topic: No interrupts  (Read 15987 times)

sand_man

  • Super Jackass
  • Jackass II
  • Posts: 54
  • Karma: +10/-0
No interrupts
« on: August 04, 2005, 03:57:01 AM »
I know that interrupts don't work in modern programming so how are we supposed to get things done in say a windows environment? Is using the windows API in assembly, like MASM32 encourages, the only way to do anything fun?

ahluka

  • Jackass IV
  • Posts: 794
  • Karma: +10/-201
No interrupts
« Reply #1 on: August 04, 2005, 04:26:31 AM »
I'm pretty certain it is, yes. At the moment I'm working on a pretty primitive 2D graphics engine that works in 320x200x256 resolution, and I'm writing it in Turbo C 2.01 meaning I can use interrupts. Actually I started writing it in TP.

I havn't looked at using the Windows API in assembly yet, but I've read about it. If you try calling an interrupt in, say, inline assembly with C++, you get an access violation.

sand_man

  • Super Jackass
  • Jackass II
  • Posts: 54
  • Karma: +10/-0
No interrupts
« Reply #2 on: August 04, 2005, 06:31:02 AM »
So you are using TC 2 under a 32-bit system?
Im not even interested in ancient graphics modes.

ahluka

  • Jackass IV
  • Posts: 794
  • Karma: +10/-201
No interrupts
« Reply #3 on: August 04, 2005, 07:00:59 AM »
Yeah.
I guess int 10h isn't that thrilling  :( but I've never done it before and thought 'hey, why not'. Gives me something to do.

Bubba

  • Jackass I
  • Posts: 10
  • Karma: +10/-0
No interrupts
« Reply #4 on: February 10, 2006, 02:33:47 AM »
Agreed.  I see no need for a 16-bit graphics API in modern 32-bit hardware.  Writing a 2D graphics lib in assembly is quite simple and I really have no use for it but good luck anyways.

Tama

  • Bitch
  • Jackass II
  • Posts: 82
  • Karma: +14/-10
No interrupts
« Reply #5 on: February 10, 2006, 10:57:19 PM »
>I know that interrupts don't work in modern programming
That's news to me. Maybe I should tell my assembly programs that use interrupts in the latest version of Windows that it doesn't work that way. :p

>Is using the windows API in assembly
The Windows API is evil incarnate no matter what language you use it with. But no, you're not restricted when you have absolute control over the machine. :rolleyes: For example, it's trivial to use the C libraries with assembly:
Code: [Select]

segment .text
global _main
extern _printf

_main:
pusha

push dword hello
call _printf
add esp, 4

popa
mov eax, 0
ret

segment .data
hello: db "Hello, world!", 10, 0

Assemble to an object file, link with the compiler of your choice, and have a nice day. :cool2:

Bubba

  • Jackass I
  • Posts: 10
  • Karma: +10/-0
No interrupts
« Reply #6 on: February 15, 2006, 06:39:31 AM »
AFAIK all interrupts work under the DOS emulator in XP.  I doubt you will be able to do TSRs and high mem stuff, but all of the interrupts I've used have worked under XP.

However, some IRQ masking, and DMA programing do not work properly under XP and XP also will not let you get a near pointer to the linear frame buffer like DOS did.

VBprogrammer

  • Back on GMT thank god
  • Jackass IV
  • Posts: 747
  • Karma: +13/-21
No interrupts
« Reply #7 on: February 19, 2006, 04:15:58 AM »
I think what Tama was pointing out is a computer without interupts is like a human without a brain, pretty darn useless (alittle extreme but polling is no fun!). The thing that you don't get in 32bit (not under the Dos emulator) programming is the BIOS interupts which do some nice things for you. Of course most modern operating systems limit access to interupts to system code.

Bubba

  • Jackass I
  • Posts: 10
  • Karma: +10/-0
No interrupts
« Reply #8 on: February 19, 2006, 07:46:00 PM »
The entire concept of no interrupts in 32-bit protected mode has nothing to do with Windows or Microsoft. It has everything to do with how Intel designed the 32-bit protected mode architecture.  In 32-bit PM drivers take the place of interrupts and so programs query and call drivers to do what interrupts used to do.

This keeps programs running at certain privilege levels and really eases programming because the driver code does all the nitty gritty.

Interrupts in protected mode are not at the same address as the IVT in real mode.  Interrupts in protected mode are routed through the IDT or interrupt descriptor table which makes use of the GDT or global descriptor table.

32-bit programming is much different from real mode.  For more information consult the Intel IA-32 technical reference manuals.

And the Windows API DOES provide functions for doing everything you could do in DOS and more.  Consult the DDK and the SDK.

VBprogrammer

  • Back on GMT thank god
  • Jackass IV
  • Posts: 747
  • Karma: +13/-21
No interrupts
« Reply #9 on: February 19, 2006, 08:04:57 PM »
The Intel arcutecture provides a number of functions which the operating system developers can deside to use...however there is nothing which forces them to do so, they could have all code running as privilaged mode if they so desired.

Bubba

  • Jackass I
  • Posts: 10
  • Karma: +10/-0
No interrupts
« Reply #10 on: February 21, 2006, 02:23:51 AM »
Which would be assinine if they did so.  However VBprogrammer is right in that privilege levels are there to use IF the OS designers feel they need to.  Really for PM all you need for any one program is 2 descriptors.  You don't have to even use a segmented model, however, I do believe Windows XP does use a segemented model rather than 2 wide open segment descriptors.  The Intel tech ref book 2 explains how to setup the PM 32 environment for code and describes several approaches one might take to setting up the descriptors.

Now you can invoke an interrupt in PM via the IDT, but this is where Windows does not allow you to.  However check out DJGPP for DOS and you will see that it allows for interrupts.  It is more inline with Intel's train of thought and design, however, to replace interrupts with driver calls and this is what modern OS's have done.

I cannot explain everything concerning protected mode programming, segment descriptors, LDT, IDT, GDT, TSS, etc, in one post.  Again go get the Intel tech refs and read em.  They are chocked full of information written by the guys who developed the CPU.  Invaluable resources.   You must get them.

This is a thread where we really need CompuBoy.  I must admit my assembly knowledge has suffered with my recent DX adventures.  DX rarely requires assembly and when it does, it's normally a fast memory copy or something like that.

VBprogrammer

  • Back on GMT thank god
  • Jackass IV
  • Posts: 747
  • Karma: +13/-21
No interrupts
« Reply #11 on: February 22, 2006, 04:44:13 PM »
Just checking bubba, have you forgotten me? I was one of the ASM/OS geeks back in the Cboy (rahaydenuk and garf also!) days on Flashdaddee.

The 4 blue books adorn my bookshelf (do they even give them away now adays?) and while i've forgotten alot, I do remember a those TLAs!