diff --git a/ka/ABI b/ka/ABI index 315448f..180ca88 100644 --- a/ka/ABI +++ b/ka/ABI @@ -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 #------------------------------------------------------------------------------# diff --git a/ka/sys/intr/common.k b/ka/sys/intr/common.k index 1c46a4c..0e6cba4 100644 --- a/ka/sys/intr/common.k +++ b/ka/sys/intr/common.k @@ -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