flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
BAiC 18 Apr 2012, 00:44
I've written a task switching mechanism which uses the LAPICs' oscillator to trigger a task switch. the code includes a Front Side Bus calculator to determine the correct value to write into the Initial Count Register.. the state machine component uses a Linked List approach. each time it is supposed to switch a task it stores the registers onto the current tasks' stack and stores the RSP register into the state machine for the current task; Then it reads in the address of the next tasks' state machine (using the linked list component) and uses it to recover RSP. The code below is on line 7485 of ORB.asm
Code: xor ecx, ecx mov[dword APIC.EOI], ecx ; mov rbx,[rdi+orb.tasks];this is used as an index. ; add rbx, rbx ; mov ecx, 16 ; min rcx, rbx, rax ; mov eax, NRQ.TSC, .init ; shr eax, 4 ; mul[rcx*8+reciprocals] ; add edx, edx ; mov[dword APIC.LVTTimerICR], edx ;tsc ;cmp rax,[rdi+orb.timeout-128] ;jb .end.int rali ., 16 .int.two: ;the empty condition. mov rsi,[rdi+orb.current-128] ;cmp rsi,[rsi+orb.next] ;je .end.int psh r08 r09 r10 r11 r12 r13 r14 r15 add rsp,-512-8 fxsave64 [rsp] inc[rdi+ orb.count] mov[rsi+ orb.rsp], rsp or [rsi+ orb.int], 1 mov rsi,[rsi+orb.next] mov rsp,[rsi+orb.rsp ] mov[rdi+ orb.current-128],rsi tst[rsi+ orb.int], 1 jz .start fxrstor64 [rsp] add rsp, 512+8 pop r15 r14 r13 r12 r11 r10 r09 r08 .end.int: ret rali ., line .start: psh NRQ.Flags, .init popf cal qword [rsi] cli lea rdi, 128 shl ORB.Multiplier + ORB.Controls, .init dec[rdi+ orb.tasks] mov rsi,[rdi+orb.current-128] mov rdx,[rsi+orb.next] mov rcx,[rsi+orb.prev] mov[rdx+orb.prev], rcx mov[rcx+orb.next], rdx mov[rdi+orb.current-128],rdx mov rax,[rsi+orb.stack] psh rdx psh rsi cal ORB.Page.D, .init;deallocate the memory used for the processes' stack. pop rax cal ORB.Line.D, .init;deallocate the memory used for the linked list block. pop rsi mov rsp,[rsi+orb.rsp] lea rdi, 128 shl ORB.Multiplier + ORB.Controls, .init inc[rdi+orb.count] tst[rsi+orb.int], 1 jz .start fxrstor64 [rsp] add rsp, 512+8 pop r15 r14 r13 r12 r11 r10 r09 r08 ret
Last edited by BAiC on 18 Apr 2012, 04:40; edited 1 time in total |
|||||||||||
![]() |
|
BAiC 18 Apr 2012, 00:55
CAL is a macro for CALL.
rali is a macro that performs Relative Alignment. since the code is copied elsewhere prior to executing the ALIGN directive doesn't generally work. fxsave64 is a macro for fxsave (with "db 0x48" to make it x64 compatible). FASM doesn't include this instruction in the version I'm using (I can't speak for current version). |
|||
![]() |
|
BAiC 18 Apr 2012, 04:39
found it. I was using the root link as a "union" and ended up writing over rsp. The code now works as it should.
|
|||
![]() |
|
bubach 18 Apr 2012, 20:45
Do you have a homepage, i would like to learn more about your system&goals as it looks like you are preforming some serious assembly wizardry in there..
![]() |
|||
![]() |
|
BAiC 19 Apr 2012, 14:22
I will eventually make a webpage about Mathis, I'm simply not ready yet. when it comes to my goals for Mathis, they're not readily apparent: I'm actually working towards a fully integral Scripting Language.
I've been focused heavily on the algorithms needed to support a parser. my current version is nothing more than a character code loop that tokenizes the input string. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.