diff options
Diffstat (limited to 'zap/source/ia32/sys')
-rw-r--r-- | zap/source/ia32/sys/syscall.s | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/zap/source/ia32/sys/syscall.s b/zap/source/ia32/sys/syscall.s new file mode 100644 index 0000000..c99cd2b --- /dev/null +++ b/zap/source/ia32/sys/syscall.s @@ -0,0 +1,34 @@ +# Copyright 2022-2023 Gabriel Jensen. +# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>. + +.globl zap_syscall + +zap_syscall: + # System calls on IA-32 use the following registers: + # eax : System call identifier + # ebx : First parameter + # ecx : Second parameter + # edx : Third parameter + # esi : Fourth parameter + # edi : Fifth parameter + # ebp : Sixth parameter + # eax : Return value + pushl %ebx # Remember to save the registers. + pushl %esi + pushl %edi + pushl %ebp # Remember that the provided paramters are now further up the stack. + movl 0x14(%esp),%eax # Move the first parameter (the identifier) to eax. + movl 0x18(%esp),%ebx # Move the remaining parameters into their designated registers. This will read "out of bounds" memory if the number of passed parameters is less than six, but this shouldn't matter as long as the data isn't being used, which it won't be as long as the expected ammount of parameters have been passed. + movl 0x1C(%esp),%ecx + movl 0x20(%esp),%edx + movl 0x24(%esp),%esi + movl 0x28(%esp),%edi + movl 0x2C(%esp),%ebp + int $0x80 # Flying city + popl %ebp # Restore the registers. + popl %edi + popl %esi + popl %ebx + # No need to move the return value. + ret |