1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
This commit is contained in:
julianb0 2019-07-09 20:16:35 +02:00
parent 4d89b8656a
commit e6d0c9ec20
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
2 changed files with 15 additions and 19 deletions

26
ka/ABI
View File

@ -19,16 +19,16 @@ A function's assembly code looks like this:
ret
'N' is the number of local variables used by the function.
The above code is equivalent to the following, but much faster:
The above code is equivalent to the following, but faster:
label:
mov [rsp-8], rbp
lea rbp, [rsp-8]
sub rsp, (N+1)*8
push rbp
mov rbp, rsp
sub rsp, N*8
...
...
...
lea rsp, [rbp+8]
mov rbp, [rbp]
mov rsp, rbp
pop rbp
ret
Between the 'enter' and the 'leave', the stack looks like this:
@ -73,7 +73,7 @@ Aside from the DF flag, a function cannot assume anything about the state
of the flags in the FLG register.
Passing parameters is done using the following registers, in that order:
ax0-ax9, a10-a31
a0-a15
The stack is never used for argument passing, except for variadic functions,
cf the next section. If you need to pass large structures of data, pass
@ -81,14 +81,14 @@ their address in an appropriate register.
Return values are passed in 'rax'. If the return value does not fit
and require more registers, use the following registers, in that order:
rax, rdx, a16-a31
rax, rdx
The following registers are volatile; the calling function cannot assume
that they will be left unmodified by the called function:
rax, rcx, rdx, rx8-r31, ax0-a31
rax, rcx, rdx, r8-r15, a0-a15
The following registers are nonvolatile; the called function must preserve them:
rbx, rsi, rdi, nx0-n31, rbp, rsp
rbx, rsi, rdi, n0-n15, rbp, rsp
#------------------------------------------------------------------------------#
@ -127,12 +127,10 @@ as an offset register in the [reg+reg(*/+...)] memory formats; in these case,
The following registers can only be used by the supervisor:
- Fast global variables for the supervisor:
sa0-sa7
- Debugging registers for the supervisor:
dr0-dr7
sa0-sa3
The following registers cannot be referenced by machine code at all:
px0-px1, fc0-fc2, cr0-cr7
px0-px1, fc0-fc2, cr0-cr3
#------------------------------------------------------------------------------#

View File

@ -2,19 +2,17 @@
; See the LICENSE file in the project root for more information.
TrapHandlers.prolog:
sub rsp, rbp, 32
sub rsp, rbp, 24
mov q[rbp-8], r11
mov q[rbp-16], r12
mov q[rbp-24], r13
cmp q[rsp], r13
crash.z
jmp rax ; go back
TrapHandlers.epilog:
mov r11, q[rbp-8]
mov r12, q[rbp-16]
mov r13, q[rbp-24]
mov r12, q[rbp-16]
mov r11, q[rbp-8]
mov ax0, r11
call IDT.DoneHandling