flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Help with ints

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 07 Jun 2011, 17:23
Hi everyone!
I want my OS to do system calls through interrupts - I have no idea how to do it. I looked at OSdev, the article is 'foggy' many things arent explained clearly. Does anybody knows where can I found a good tutorial on that subject???

_________________
_______________________________
NSOS
Post 07 Jun 2011, 17:23
View user's profile Send private message Reply with quote
xleelz



Joined: 12 Mar 2011
Posts: 86
Location: In Google Code Server... waiting for someone to download me
xleelz 07 Jun 2011, 17:31
Well, I'm not sure if it helps but the source code to Coty's HeliumOS can be found at http://board.flatassembler.net/topic.php?t=12410

He uses kernel interrupts to print the characters 'A' and 'B' to the screen.

_________________
The person you don't know is the person that could help you the most... or rape you, whichever they prefer.
Post 07 Jun 2011, 17:31
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 08 Jun 2011, 23:24
Interrupts are terribly easy. Here is a sample code to simulate int 21h, function 02h. Remember, keep your interrupt vectors in a safe place in memory! Otherwise unwanted instructions could be executed and hang the machine.
Code:
call set_interrupt
*YOUR CODE
ivt:
 pushf ; save flags
 cmp ah, 02h ; DOS interrupt function 02h (print character)
 jnz int_ret ; not our function, then leave
 push ax ; save AX
 mov al, dl ; move the character from dl to al
 mov ah, 0eh ; Teletype BIOS function
 int 10h ; print character
 pop ax ; restore AX
int_ret:
 popf ; restore flags
 iret ; interrupt return (basically retf)
set_interrupt:
push es ; save ES
push 0
pop es ; lets zero out es
cli ; disable interrupts
mov word[es:21h*4], ivt ; formula for this is "Interrupt*4 = offset"
mov word[es:21h*4+2], cs ; we must put our segment after the offset
sti ; enable interrupts
pop es ; restore ES
ret ; return to our code
    
Post 08 Jun 2011, 23:24
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 09 Jun 2011, 10:30
me239 wrote:
Interrupts are terribly easy. Here is a sample code to simulate int 21h, function 02h. Remember, keep your interrupt vectors in a safe place in memory! Otherwise unwanted instructions could be executed and hang the machine.
Code:
call set_interrupt
*YOUR CODE
ivt:
 pushf ; save flags
 cmp ah, 02h ; DOS interrupt function 02h (print character)
 jnz int_ret ; not our function, then leave
 push ax ; save AX
 mov al, dl ; move the character from dl to al
 mov ah, 0eh ; Teletype BIOS function
 int 10h ; print character
 pop ax ; restore AX
int_ret:
 popf ; restore flags
 iret ; interrupt return (basically retf)
set_interrupt:
push es ; save ES
push 0
pop es ; lets zero out es
cli ; disable interrupts
mov word[es:21h*4], ivt ; formula for this is "Interrupt*4 = offset"
mov word[es:21h*4+2], cs ; we must put our segment after the offset
sti ; enable interrupts
pop es ; restore ES
ret ; return to our code
    

I'm developing Pmode OS and Pmode IDT

_________________
_______________________________
NSOS
Post 09 Jun 2011, 10:30
View user's profile Send private message Reply with quote
me239



Joined: 06 Jan 2011
Posts: 200
me239 09 Jun 2011, 19:11
BOTOKILLER wrote:

I'm developing Pmode OS and Pmode IDT
I don't know how segmented memory preforms in Pmode (since Interrupt Vectors are in Segment:Offset), but you can skip the BIOS interrupt 10h and just write them to the video buffer.
Code:
ivt:
pushf
cmp ah, 02h
jz int_ret
push ax es
push 0b800h
pop es
mov ah, 07h
stosw
pop es ax
int_ret:
popf
iret
    

I believe that 16 and 8 bit registers should still work in Pmode.
Post 09 Jun 2011, 19:11
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.