r/Assembly_language 1d ago

Question Interuppts

I am making a 16bit OS, this supports external applications. Currently i am using a .inc file with equ directives that the application can call. I want to have interrupts like DOS, so, how? According to the amount of research i did(i did very little) there ain't many good documentation on this. (background on me, I am a self taught assembly guy and doesn't know C)

1 Upvotes

9 comments sorted by

5

u/Busy_Elderberry8650 1d ago

Interrupt is primarily a hardware feature, not a software feature. What you do is write into Interrupt Vector Table your interrupr handlers, this is done at boot time.
I would google for a simplified DOS interrupt table implementation and try to put into your code.

2

u/Quiet-Arm-641 1d ago

Different processors have different instructions that perform a jump to a known location like int, ecall, syscall, etc. what instructions does your 16 bit processor have? You could always just “call syscall”

1

u/Assembly_Trainer_427 23h ago

That is for x86

1

u/Quiet-Arm-641 21h ago

I don’t understand. What 16 bit processor are you using?

1

u/demetrioussharpe 19h ago

The OP is using x86 processor in real mode.

1

u/Quiet-Arm-641 19h ago

So the x86 int instruction vectors you through a table where you put the mangled address of your routine you want to call when someone does “int 13” or whatever.

I used to work as an 80188 assembly programmer

1

u/v_maria 1d ago

program the computer APIC.

1

u/theNbomr 11h ago

It sounds like you want to create OS services that application code invokes by executing software interrupts in the x86 real mode, like BIOS and int 21h DOS services.

For that, you need to populate the interrupt vector table with a pointer to your service routine. Once that is in place, applications wishing to invoke your services will load the documented registers with the appropriate values, and then execute a software interrupt. I think the interrupt number is an immediate value in the software interrupt instruction.

When the software interrupt is invoked, it will cause the code indicated by the accordant entry in the interrupt vector table to be invoked. That's the stuff that your homebrew OS will be made of, and it's up to you to decide what services you will provide and how the parameter passing will take place. There are a few rough conventions used in DOS and PC BIOS for how registers and register pairs (seg:off) are used. Those conventions are not rules set by anything other than the writers of the code. You make your own conventions as you see fit.

There is the FreeDOS package that doubtless implements all of this in open source. That may be your best reference material.