Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
void set_interrupt(char c,void* a){
asm("push %es ;save es");
asm("xor %es,%es ;null out es");
asm("mov %al,%0 ;set al to int number"::"g"(c):);
asm("mov %bl,0x4 ;prepare mul by 0x4");
asm("mul %bl ;multiply al by 0x4");
asm("mov %bx,%ax ;mov result to bx");
asm("mov es:(bx),%0"::"m"(a):);
asm("add %bx,$2");
asm("mov es:(bx), segment");
asm("pop %es ;restore es ");
}
How should I get segment from a to pass it on this line
1. learn function pointer (instead of passing void* a)
2. interrupt vector should have range 0<= vector < 256, which requires at least unsigned char to hold full range
3. C function may use ABI that trash some registers, and not suitable for direct interrupt handler (unless special compiler specific attributes).
For C programming with real mode x86, how to retrieve the segment of a pointer depends on the memory model,
for example with far pointer, the segment is the first two bytes of the pointer.