
Gibt es eine Möglichkeit, dass der folgende Code, der ja nun eigentlich wirklich keinen Stack braucht, vom gcc (bzw jedem anderen) C-Compiler auch ohne Stack kompiliert wird, oder muss ich auf Assembler zurückgreifen?
Code: Alles auswählen
INTO_SECTION( void switchtask(IRQ_Information *r), ".linked" )
{
	if (*MyPriorityLeft > 0) {
		(*MyPriorityLeft)--;
	} else {
		asm volatile("mov %%esp, %0" : "=r"(*My_esp));
		*My_eip = read_eip();
		if (*My_eip == 0x123) {
			return;
		}
		*MyPriorityLeft = *MyPriority;
		enable_paging(*NextTask_cr3);
		asm volatile("cli");
		asm volatile("mov %0, %%ecx" : : "r"(*My_eip));
		asm volatile("mov %0, %%esp" : : "r"(*My_esp));
		asm volatile("mov $0x123, %eax");
		asm volatile("sti");
		asm volatile("jmp *%ecx");
	}
} Code: Alles auswählen
ffc00000 <switchtask>:
ffc00000:	55                   	push   %ebp
ffc00001:	89 e5                	mov    %esp,%ebp
ffc00003:	53                   	push   %ebx
ffc00004:	83 ec 14             	sub    $0x14,%esp
ffc00007:	a1 ac 06 c0 ff       	mov    0xffc006ac,%eax
ffc0000c:	8b 00                	mov    (%eax),%eax
ffc0000e:	85 c0                	test   %eax,%eax
ffc00010:	74 0e                	je     ffc00020 <switchtask+0x20>
ffc00012:	a1 ac 06 c0 ff       	mov    0xffc006ac,%eax
ffc00017:	8b 10                	mov    (%eax),%edx
ffc00019:	83 ea 01             	sub    $0x1,%edx
ffc0001c:	89 10                	mov    %edx,(%eax)
ffc0001e:	eb 60                	jmp    ffc00080 <switchtask+0x80>
ffc00020:	a1 b8 06 c0 ff       	mov    0xffc006b8,%eax
ffc00025:	89 e2                	mov    %esp,%edx
ffc00027:	89 10                	mov    %edx,(%eax)
ffc00029:	8b 1d bc 06 c0 ff    	mov    0xffc006bc,%ebx
ffc0002f:	e8 73 06 00 00       	call   ffc006a7 <read_eip>
ffc00034:	89 03                	mov    %eax,(%ebx)
ffc00036:	a1 bc 06 c0 ff       	mov    0xffc006bc,%eax
ffc0003b:	8b 00                	mov    (%eax),%eax
ffc0003d:	3d 23 01 00 00       	cmp    $0x123,%eax
ffc00042:	74 3b                	je     ffc0007f <switchtask+0x7f>
ffc00044:	a1 ac 06 c0 ff       	mov    0xffc006ac,%eax
ffc00049:	8b 15 b0 06 c0 ff    	mov    0xffc006b0,%edx
ffc0004f:	8b 12                	mov    (%edx),%edx
ffc00051:	89 10                	mov    %edx,(%eax)
ffc00053:	a1 b4 06 c0 ff       	mov    0xffc006b4,%eax
ffc00058:	8b 00                	mov    (%eax),%eax
ffc0005a:	89 04 24             	mov    %eax,(%esp)
ffc0005d:	e8 0f 04 00 00       	call   ffc00471 <enable_paging>
ffc00062:	fa                   	cli    
ffc00063:	a1 bc 06 c0 ff       	mov    0xffc006bc,%eax
ffc00068:	8b 00                	mov    (%eax),%eax
ffc0006a:	89 c1                	mov    %eax,%ecx
ffc0006c:	a1 b8 06 c0 ff       	mov    0xffc006b8,%eax
ffc00071:	8b 00                	mov    (%eax),%eax
ffc00073:	89 c4                	mov    %eax,%esp
ffc00075:	b8 23 01 00 00       	mov    $0x123,%eax
ffc0007a:	fb                   	sti    
ffc0007b:	ff e1                	jmp    *%ecx
ffc0007d:	eb 01                	jmp    ffc00080 <switchtask+0x80>
ffc0007f:	90                   	nop
ffc00080:	83 c4 14             	add    $0x14,%esp
ffc00083:	5b                   	pop    %ebx
ffc00084:	5d                   	pop    %ebp
ffc00085:	c3                   	ret    Außerdem zählt hier wirklich jede Anweisung weniger, da dieser Code nunmal 100 - 10000 mal pro Sekunde aufgerufen wird.


