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
|
||||
'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:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
@ -36,16 +36,14 @@ Between the 'enter' and the 'leave', the stack looks like this:
|
||||
. .
|
||||
. (caller's) .
|
||||
|---------------|
|
||||
| saved rip | rbp+8
|
||||
| saved rbp | rbp+0
|
||||
| . | rsp+(N*8) \
|
||||
| . | ... |
|
||||
| . | ... |
|
||||
| . | ... |- Local variables
|
||||
| . | rsp+16 |
|
||||
| . | rsp+8 |
|
||||
| . | rsp+0 /
|
||||
|---------------|
|
||||
| saved rip | rbp+8 rsp+(N*8)+16
|
||||
| saved rbp | rbp rsp+(N*8)+8
|
||||
| . | rbp-8 rsp+(N*8) \
|
||||
| . | rbp-16 rsp+(N-1)*8 |
|
||||
| . | ... | <- local
|
||||
| . | rbp-(N-1)*8 rsp+8 | variables
|
||||
| . | rbp-(N*8) rsp |
|
||||
|---------------| /
|
||||
. (red zone) .
|
||||
. .
|
||||
. .
|
||||
|
@ -28,9 +28,6 @@ start:
|
||||
|
||||
call main
|
||||
|
||||
mov rax, Sys.Exit
|
||||
trap 0
|
||||
|
||||
crash
|
||||
|
||||
;
|
||||
|
@ -28,11 +28,16 @@ InitSyscalls:
|
||||
|
||||
ret
|
||||
|
||||
SwitchToCMD:
|
||||
mov rax, Sys.Exit
|
||||
trap 0
|
||||
|
||||
;
|
||||
; Main function
|
||||
;
|
||||
main:
|
||||
call PrintBootMsg
|
||||
call InitSyscalls
|
||||
call SwitchToCMD
|
||||
ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user