1 ;; Native x86 GNU/Linux Forth System, Direct Threaded Code
3 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
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.
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/>.
17 urword_value
"STDIN-FD",stdin_fd
,0
18 urword_value
"STDOUT-FD",stdout_fd
,1
19 urword_value
"STDERR-FD",stderr_fd
,2
21 if TTYLOW_ALLOW_BUFFERED
22 urword_value
"(TTY-LOW-USE-BUFFER)",par_ttylow_use_buffer
,1
24 urword_value
"(TTY-LOW-BUFFER-ADDR)",par_ttylow_buffer_addr
,0
26 urword_value
"(TTY-LOW-BUFFER-POS)",par_ttylow_buffer_pos
,0
28 urword_value
"(TTY-LOW-BUFFER-SIZE)",par_ttylow_buffer_size
,32768
32 urword_var
"(EMIT-COL)",par_emit_col
,0
35 urword_code
"(TTY-LOW-FLUSH)",par_ttylow_flush
42 if TTYLOW_ALLOW_BUFFERED
43 ld
eax,[fval_par_ttylow_buffer_pos_data
]
49 mov ebx,[fval_stdout_fd_data
]
50 mov ecx,[fval_par_ttylow_buffer_addr_data
]
51 mov edx,[fval_par_ttylow_buffer_pos_data
]
55 ld
dword [fval_par_ttylow_buffer_pos_data
],0
61 urword_code
"(RESET-EMIT-COL)",par_reset_emitcol
63 urword_uses par_ttylow_flush
65 ;call fttylow_do_flush
66 ld
dword [fvar_par_emit_col_data
],0
70 ;; this will also flush buffer
71 urword_code
"(EMIT-FIX-COL-CODEBLOCK)",par_emit_fixcol_codeblock
76 urword_uses par_ttylow_flush
80 ;call fttylow_do_flush
81 ld
dword [fvar_par_emit_col_data
],0
86 ;call fttylow_do_flush
87 ld
dword [fvar_par_emit_col_data
],0
90 if TTYLOW_ALLOW_BUFFERED
= 0
93 ld
eax,[fvar_par_emit_col_data
]
96 ld
[fvar_par_emit_col_data
],eax
102 cp
dword [fvar_par_emit_col_data
],0
104 dec dword [fvar_par_emit_col_data
]
110 inc dword [fvar_par_emit_col_data
]
115 urword_code
"(EMIT-FIX-COL)",par_emit_fixcol
118 call emit_fix_col_subr
122 urword_code
"(EMIT)",paremit
123 urword_uses par_ttylow_flush
125 call emit_fix_col_subr
126 if TTYLOW_ALLOW_BUFFERED
133 ld
eax,[fvar_par_emit_col_data
]
135 ld
[fvar_par_emit_col_data
],eax
148 cp
dword [fval_par_ttylow_use_buffer_data
],1
150 ld
eax,[fval_par_ttylow_buffer_pos_data
]
151 cp
eax,[fval_par_ttylow_buffer_size_data
]
153 add eax,[fval_par_ttylow_buffer_addr_data
]
156 inc dword [fval_par_ttylow_buffer_pos_data
]
159 call fttylow_do_flush
162 call fttylow_do_flush
168 mov ebx,[fval_stdout_fd_data
]
169 mov ecx,esp ; address
175 if TTYLOW_ALLOW_BUFFERED
183 urword_code
"(CR)",parcr
191 urword_code
"(BELL)",parbell
199 mov ebx,[fval_stdout_fd_data
]
200 mov ecx,esp ; address
209 urword_code
"(ENDCR)",parendcr
212 cp
dword [fvar_par_emit_col_data
],0
219 urword_code
"(?ENDCR)",parqendcr
223 cp
dword [fvar_par_emit_col_data
],0
231 urword_code
"(TYPE)",partype
232 urword_uses par_ttylow_flush
233 ;; ( addr length -- )
241 call fttylow_do_flush
246 call emit_fix_col_subr
255 mov ebx,[fval_stdout_fd_data
]
270 urword_code
"(GETCH)",pargetch
271 urword_uses par_ttylow_flush
275 call fttylow_do_flush
279 ld
ebx,[fval_stdin_fd_data
]
280 mov ecx,esp ; address