mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
abi
This commit is contained in:
parent
498e46ddc8
commit
1cd5286440
20
ka/ABI
20
ka/ABI
@ -19,7 +19,7 @@ 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 faster:
|
The above code is equivalent to (and can be substitued by) the following:
|
||||||
label:
|
label:
|
||||||
push rbp
|
push rbp
|
||||||
mov rbp, rsp
|
mov rbp, rsp
|
||||||
@ -36,16 +36,14 @@ Between the 'enter' and the 'leave', the stack looks like this:
|
|||||||
. .
|
. .
|
||||||
. (caller's) .
|
. (caller's) .
|
||||||
|---------------|
|
|---------------|
|
||||||
| saved rip | rbp+8
|
| saved rip | rbp+8 rsp+(N*8)+16
|
||||||
| saved rbp | rbp+0
|
| saved rbp | rbp rsp+(N*8)+8
|
||||||
| . | rsp+(N*8) \
|
| . | rbp-8 rsp+(N*8) \
|
||||||
| . | ... |
|
| . | rbp-16 rsp+(N-1)*8 |
|
||||||
| . | ... |
|
| . | ... | <- local
|
||||||
| . | ... |- Local variables
|
| . | rbp-(N-1)*8 rsp+8 | variables
|
||||||
| . | rsp+16 |
|
| . | rbp-(N*8) rsp |
|
||||||
| . | rsp+8 |
|
|---------------| /
|
||||||
| . | rsp+0 /
|
|
||||||
|---------------|
|
|
||||||
. (red zone) .
|
. (red zone) .
|
||||||
. .
|
. .
|
||||||
. .
|
. .
|
||||||
|
@ -28,9 +28,6 @@ start:
|
|||||||
|
|
||||||
call main
|
call main
|
||||||
|
|
||||||
mov rax, Sys.Exit
|
|
||||||
trap 0
|
|
||||||
|
|
||||||
crash
|
crash
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -28,11 +28,16 @@ InitSyscalls:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
SwitchToCMD:
|
||||||
|
mov rax, Sys.Exit
|
||||||
|
trap 0
|
||||||
|
|
||||||
;
|
;
|
||||||
; Main function
|
; Main function
|
||||||
;
|
;
|
||||||
main:
|
main:
|
||||||
call PrintBootMsg
|
call PrintBootMsg
|
||||||
call InitSyscalls
|
call InitSyscalls
|
||||||
|
call SwitchToCMD
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user