mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
vm
This commit is contained in:
parent
4d89b8656a
commit
e6d0c9ec20
26
ka/ABI
26
ka/ABI
@ -19,16 +19,16 @@ A function's assembly code looks like this:
|
|||||||
ret
|
ret
|
||||||
'N' is the number of local variables used by the function.
|
'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:
|
label:
|
||||||
mov [rsp-8], rbp
|
push rbp
|
||||||
lea rbp, [rsp-8]
|
mov rbp, rsp
|
||||||
sub rsp, (N+1)*8
|
sub rsp, N*8
|
||||||
...
|
...
|
||||||
...
|
...
|
||||||
...
|
...
|
||||||
lea rsp, [rbp+8]
|
mov rsp, rbp
|
||||||
mov rbp, [rbp]
|
pop rbp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
Between the 'enter' and the 'leave', the stack looks like this:
|
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.
|
of the flags in the FLG register.
|
||||||
|
|
||||||
Passing parameters is done using the following registers, in that order:
|
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,
|
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
|
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
|
Return values are passed in 'rax'. If the return value does not fit
|
||||||
and require more registers, use the following registers, in that order:
|
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
|
The following registers are volatile; the calling function cannot assume
|
||||||
that they will be left unmodified by the called function:
|
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:
|
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:
|
The following registers can only be used by the supervisor:
|
||||||
- Fast global variables for the supervisor:
|
- Fast global variables for the supervisor:
|
||||||
sa0-sa7
|
sa0-sa3
|
||||||
- Debugging registers for the supervisor:
|
|
||||||
dr0-dr7
|
|
||||||
|
|
||||||
The following registers cannot be referenced by machine code at all:
|
The following registers cannot be referenced by machine code at all:
|
||||||
px0-px1, fc0-fc2, cr0-cr7
|
px0-px1, fc0-fc2, cr0-cr3
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
@ -2,19 +2,17 @@
|
|||||||
; See the LICENSE file in the project root for more information.
|
; See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
TrapHandlers.prolog:
|
TrapHandlers.prolog:
|
||||||
sub rsp, rbp, 32
|
sub rsp, rbp, 24
|
||||||
mov q[rbp-8], r11
|
mov q[rbp-8], r11
|
||||||
mov q[rbp-16], r12
|
mov q[rbp-16], r12
|
||||||
mov q[rbp-24], r13
|
mov q[rbp-24], r13
|
||||||
cmp q[rsp], r13
|
|
||||||
crash.z
|
|
||||||
|
|
||||||
jmp rax ; go back
|
jmp rax ; go back
|
||||||
|
|
||||||
TrapHandlers.epilog:
|
TrapHandlers.epilog:
|
||||||
mov r11, q[rbp-8]
|
|
||||||
mov r12, q[rbp-16]
|
|
||||||
mov r13, q[rbp-24]
|
mov r13, q[rbp-24]
|
||||||
|
mov r12, q[rbp-16]
|
||||||
|
mov r11, q[rbp-8]
|
||||||
|
|
||||||
mov ax0, r11
|
mov ax0, r11
|
||||||
call IDT.DoneHandling
|
call IDT.DoneHandling
|
||||||
|
Loading…
Reference in New Issue
Block a user