flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > IVT Setup/Layout |
Author |
|
edfed 16 Nov 2007, 15:32
an interrupt is a routine thats ends with iret
an int vector is a 16 bit far pointer so you just have to build the pointers for your routines there is a DOS int to make this but the best is to direct memory write int vector for int 0 is located at linear 0 int vector for int 1 is located at linear 4 int vector for int 2 is located at linear 8 int vector for int 3 is located at linear 12 etc etc... to change the int vector, you first must cli then change the vectors ( farpointers ) and sti |
|||
16 Nov 2007, 15:32 |
|
rhyno_dagreat 16 Nov 2007, 16:04
Wow! It's that simple?
Thanks. |
|||
16 Nov 2007, 16:04 |
|
Dex4u 17 Nov 2007, 13:54
In realmode it very simple eg:
Code: Installints:push ds ; Save DScli ; Turn off int'sxor ax,axmov ds,ax ; 0 DSmov word [ds:21h*4],int21 ; load int vecter with int21h addressmov word [ds:21h*4+2],cs ; + CSsti ; Turn on int'spop ds ; restore DSret ; Returnint21: ;You would come here on int 21hiret ; Int return. You should also save the regs and you can cmp AH like this Code: cmp ah,0 ; Does AH = 0je int21_00 ; Terminate programcmp ah,1 ; Does AH = 1je int21_01 ; Read char with echocmp ah,2 ; Does AH = 2je int21_02 ; Write charcmp ah,7 ; Does AH = 7je int21_07 ; Read char without echocmp ah,8 ; Does AH = 8je int21_07 ; Read char;more code here |
|||
17 Nov 2007, 13:54 |
|
edfed 17 Nov 2007, 14:42
you can also save cpu time with a sub int vector table if you have a lot of sub function
instead of testing all possibles ah values, you direct call the good function after some fixed time computation very important to be the more real time possible but it consumme more memory and is harder to debug not good for size optimisation but good for speed & system optimisation, you can easilly change the sub code offset! note that all PC since 1998 have a lot of memory >32 Mb ram, >2Gbytes Hd so for modern Os, using all the first linear megabyte for basic kernel is not a problem Code: int_XX: push ds cs ;saving ds pop ds ;asssume ds=cs push eax ;save eax and eax,0ffh ;limit eax to 255 cmp eax,[.svt] ;is subfunction out of SubVector Table? jg .error mov eax,[eax*4+.svt+4] ;look into the SVT cmp eax,0 ;is function supported? je .error call eax ;call, not jump, the sub function pop eax ;restore context pop ds or eax,10000000h ;eax =/= 0 then OK iret ;and finally iret .error: pop eax pop ds mov eax,0 ;eax == 0 then error iret .svt: dd @f-$-2 ;size of subvetor table in bytes dd .0 dd .1 dd .2 dd 0 dd .3 dd 0 ;int XX.4 doesn't exists dd .5 dd .6 dd .na ;int XX.7 is unassigned dd .na dd .0 dd .a rd 4fh dd .5ah dd .5bh @@: ;end of subvector table .0: ;int XX.0 code ret .1: ;int XX.1 code ret .2: ;int XX.2 code ret .3: ;int XX.3 code ret .4: ;int XX.4 code ret .5: ;int XX.5 code ret ;not supported sub vectors .6: .7: .8: .9: .a: .b: .c: .d: .e: .f: .10: .11: .12: .na: ;not assigned .5ah: .5bh: ret this is not tested because i don't use int until december! could that kind of code have a chance to be adopted? |
|||
17 Nov 2007, 14:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.