l0, meta, l1: added "+0" and "-0" conditionals; updated prebuilt binary
[urforth.git] / level0 / urforth0_w_syscall.asm
blob2ee1e06362f8adf71f1abbce6c2de7108d479613
1 ;; Native x86 GNU/Linux Forth System, Direct Threaded Code
2 ;;
3 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
4 ;;
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, version 3 of the License ONLY.
8 ;;
9 ;; This program is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;; GNU General Public License for more details.
14 ;; You should have received a copy of the GNU General Public License
15 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 urword_code "BYE",bye
20 urword_noreturn
21 urword_uses par_ttylow_flush
22 call fttylow_do_flush
23 mov eax,1
24 xor ebx,ebx
25 syscall
26 urword_end
28 urword_code "N-BYE",nbye
29 urword_noreturn
30 urword_uses par_ttylow_flush
31 ;; ( exitcode -- )
32 call fttylow_do_flush
33 mov eax,1
34 mov ebx,TOS
35 syscall
36 urword_end
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 urword_code "(SYSCALL-0)",par_syscall_0
41 ;; ( num -- res )
42 ld eax,TOS
43 push EIP ; just in case
44 syscall
45 pop EIP
46 ld TOS,eax
47 urnext
48 urword_end
50 urword_code "(SYSCALL-1)",par_syscall_1
51 ;; ( arg0 num -- res )
52 ld eax,TOS
53 pop ebx
54 push EIP ; just in case
55 syscall
56 pop EIP
57 ld TOS,eax
58 urnext
59 urword_end
61 urword_code "(SYSCALL-2)",par_syscall_2
62 ;; ( arg0 arg1 num -- res )
63 ld eax,TOS
64 pop ecx
65 pop ebx
66 push EIP ; just in case
67 syscall
68 pop EIP
69 ld TOS,eax
70 urnext
71 urword_end
73 urword_code "(SYSCALL-3)",par_syscall_3
74 ;; ( arg0 arg1 arg2 num -- res )
75 ld eax,TOS
76 pop edx
77 pop ecx
78 pop ebx
79 push EIP ; just in case
80 syscall
81 pop EIP
82 ld TOS,eax
83 urnext
84 urword_end
86 urword_code "(SYSCALL-4)",par_syscall_4
87 ;; ( arg0 arg1 arg2 arg3 num -- res )
88 ; this cannot be called recursively anyway
89 ld [fword_syscall4_eip_store],EIP
90 ld eax,TOS
91 pop esi
92 pop edx
93 pop ecx
94 pop ebx
95 syscall
96 ld EIP,[fword_syscall4_eip_store]
97 ld TOS,eax
98 urnext
99 fword_syscall4_eip_store: dd 0
100 urword_end
102 urword_code "(SYSCALL-5)",par_syscall_5
103 ;; ( arg0 arg1 arg2 arg3 arg4 num -- res )
104 ; this cannot be called recursively anyway
105 ld [fword_syscall5_eip_store],EIP
106 ld eax,TOS
107 pop edi
108 pop esi
109 pop edx
110 pop ecx
111 pop ebx
112 syscall
113 ld EIP,[fword_syscall5_eip_store]
114 ld TOS,eax
115 urnext
116 fword_syscall5_eip_store: dd 0
117 urword_end
120 urword_code "(BRK)",par_sbrk
121 ;; ( newaddr -- newaddr )
122 ;; returns current address if the request is invalid
123 push EIP ; just in case
124 ld eax,45 ; brk
125 ld ebx,TOS ; new address
126 syscall
127 ld TOS,eax
128 pop EIP
129 urnext
130 urword_end
132 urword_forth "(BRK?)",par_brkq
133 ;; ( -- curraddr )
134 UF 0 par_sbrk
135 urword_end