libk  Check-in [481509e134]

Overview
Comment:don't clobber callee-saved registers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 481509e13402141fbdaf5072c2e75a0369371a5fcef1c6dfbc2235d27dbaa2b5
User & Date: lexi on 2019-10-21 04:28:46
Other Links: manifest | tags
Context
2019-10-22
22:21
Add errno locations for Android, as an initial step check-in: 357c708c52 user: glow tags: trunk
19:43
Add default errno locations for building on Android with Termux Should probably be revised, but this is a starting point. Leaf check-in: 960d952eed user: glowpelt tags: BAD
2019-10-21
04:28
don't clobber callee-saved registers check-in: 481509e134 user: lexi tags: trunk
01:46
fix broken commit check-in: bdb84af41a user: lexi tags: trunk
Changes

Modified mod/kcore/syscall.fn.x86.lin.64.s from [856b7532d5] to [3fa83c18de].

31
32
33
34
35
36
37







38
39
40
41
42
43
44
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96




97
	; locals: rbx = s64* result
	;         r12 = u64* errno
	; arg 0 = s64* result
	; arg 1 = errno ptr
	; arg 2 = syscall num
	; arg 3 = valency
	; arg 4 = args ptr








	; store the locals in registers that
	; are guaranteed not to be clobbered,
	; saving us some cycles pushing to
	; and popping back from the stack
	mov rbx, ccall.reg.0
	mov r12, ccall.reg.1
................................................................................
	js .error ; jump if sign flag set
	
	; move our return values into place and
	; return to the caller (which should
	; always be k_platform_syscall, btw)
	mov       [rbx], sys.reg.ret
	mov qword [r12], 0 ; no error
	ret

	; an error was returned - we need to set
	; the errno to its positive equivalent,
	; and store -1 in the return variable
	.error: neg sys.reg.ret
	        mov qword [rbx], -1
			mov       [r12], sys.reg.ret




			ret







>
>
>
>
>
>
>







 







|







>
>
>
>
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
	; locals: rbx = s64* result
	;         r12 = u64* errno
	; arg 0 = s64* result
	; arg 1 = errno ptr
	; arg 2 = syscall num
	; arg 3 = valency
	; arg 4 = args ptr

	; we use two registers that are supposed
	; to be callee-saved, so we need to
	; push them to the stack and then pop
	; them back off just before the fn rets.
	push rbx
	push r12

	; store the locals in registers that
	; are guaranteed not to be clobbered,
	; saving us some cycles pushing to
	; and popping back from the stack
	mov rbx, ccall.reg.0
	mov r12, ccall.reg.1
................................................................................
	js .error ; jump if sign flag set
	
	; move our return values into place and
	; return to the caller (which should
	; always be k_platform_syscall, btw)
	mov       [rbx], sys.reg.ret
	mov qword [r12], 0 ; no error
	jmp .return

	; an error was returned - we need to set
	; the errno to its positive equivalent,
	; and store -1 in the return variable
	.error: neg sys.reg.ret
	        mov qword [rbx], -1
			mov       [r12], sys.reg.ret
			jmp .return

	.return: pop r12
	         pop rbx
			 ret