os/cpu/i386/tasking_helpers.s

50 lines
1.1 KiB
ArmAsm
Raw Normal View History

2019-02-11 09:30:28 -06:00
.section .text
.global switchTask
switchTask:
pusha
pushf
push %eax
mov 44(%esp), %eax #The first argument, where to save
mov %ebx, 4(%eax)
mov %ecx, 8(%eax)
mov %edx, 12(%eax)
mov %esi, 16(%eax)
mov %edi, 20(%eax)
mov 36(%esp), %ebx #EAX
mov 40(%esp), %ecx #IP
mov 20(%esp), %edx #ESP
add $4, %edx #Remove the return value ;)
mov 16(%esp), %esi #EBP
mov 4(%esp), %edi #EFLAGS
mov %ebx, (%eax)
mov %edx, 24(%eax)
mov %esi, 28(%eax)
mov %ecx, 32(%eax)
mov %edi, 36(%eax)
2019-02-25 15:42:23 -06:00
pop %ebx
2019-02-11 09:30:28 -06:00
push %ebx #Goodbye again ;)
mov 48(%esp), %eax #Now it is the new object
mov 4(%eax), %ebx #EBX
mov 8(%eax), %ecx #ECX
mov 12(%eax), %edx #EDX
mov 16(%eax), %esi #ESI
mov 20(%eax), %edi #EDI
mov 28(%eax), %ebp #EBP
push %eax
mov 36(%eax), %eax #EFLAGS
push %eax
popf
pop %eax
mov 24(%eax), %esp #ESP
push %eax
pop %eax
push %eax
mov 32(%eax), %eax #EIP
xchg (%esp), %eax #We do not have any more registers to use as tmp storage
mov (%eax), %eax #EAX
ret #This ends all!
.global readEip
readEip:
pop %eax
jmp %eax