Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order


FRANCE [Lyon],
25.04.2018, 12:00
(edited by cpcdos, 25.04.2018, 15:21)

Task switching interrupted stack problem (Developers)


After my previous threads, i've found alternatives for create an ISR with DPMI interrupt and 1Ch timer.

My work is to switch stack between 2 or more functions (Preemptible multi-task) between main, _mytask1 and _mytask_2 functions

For begin, this is my code FreeBasic/GAS (AT&T)

============ INIT_INTERRUPT() ============

jmp saut_1%f
DS_SEL: .short 0
INT1C_OFF: .int 0
INT1C_SEL: .short 0

push ds
pop DS_SEL
push cs
pop WORD PTR [cs_]
push ds
pop WORD PTR [ds_]
push es
pop WORD PTR [es_]
push ss
pop WORD PTR [ss_]

mov ax, 0x204
mov bl, 0x1c
int 0x31
jc saut_2%f
mov INT1C_SEL, cx
mov INT1C_OFF, edx

============ START_INTERRUPT() ============

mov ax, 0x205
mov bl, 0x1c
push cs
pop cx
int 0x31
jc saut_3%f

This code work perfectly, MY_INTERRUPT_FUNCTION() is executed during "1Ch tic"

And this is my problem :
============ MY_INTERRUPT_FUNCTION() ============
' Save registers
push ds
push es
push fs
push gs

' Entry point of DS
mov dx, ds

' Load data section in DS
mov ax, cs:DS_SEL
mov ds, ax

' Restaure seg values
mov ax, cs
mov cs_, ax
mov ds_, dx
mov ax, es
mov es_, ax
mov ax, ss
mov ss_, ax

mov fs_, fs
mov gs_, gs

' Push all registers on stack

' ===== SWITCH STACK =====
push esp
mov esp, eax
pop esp
' ===== SWITCH STACK =====

' Restaure registers

pop gs
pop fs
pop es
pop ds


This not work, iret return to the original EIP position, so i search how interrupt stack work, according this stack representation (Without error code) : [image]

About iret instruction, if i want modify the "Return EIP register" i must push my new EIP on it ? Yes ? So after my CALL, i push like this _mytask1 for test :
push eax
mov eax, _mytask1
mov ss:[esp]+0, eax
pop eax

But this not work..

I've seeing the content of "ss:[ESP]+0", the famous "Return EIP" before modifications, and i've every "0x16F".. what?? :-|

I've already executed on ring0, with cwsdpr0.exe on DOS..
I'm lost, if someone can help me?

Thank you a lot,

Sébastien FAVIER

ps: Excuse me for my English level, I'm a French student

Back to the board
Thread view  Mix view  Order
15347 Postings in 1387 Threads, 254 registered users, 8 users online (0 registered, 8 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum