added some "immediate-noop" words, removed some "$if"
[urforth.git] / level0 / meta / meta-mem.f
blobb2a791b23640fd17a573f8cca1f08060fb069a4f
1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; Native x86 GNU/Linux Forth System
3 ;; metacompiler
4 ;;
5 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
6 ;;
7 ;; This program is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, version 3 of the License ONLY.
11 ;; This program is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 ;; metacompiler target buffer
20 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 $08048000 value elf-base-rva
25 0 value elf-entry-point-addr ;; not rva
26 0 value elf-code-size-addr ;; not rva
27 0 value elf-import-table-rva
28 0 value elf-import-table-size
31 ;; allocate memory for target image
32 ;; its virtual address is elf-base-rva
33 ;; 1MB should be more than enough
34 1024 1024 * constant elf-target-memory-size
35 elf-target-memory-size brk-buffer: elf-target-memory
37 elf-base-rva value elf-current-pc ;; rva
40 : tc->real ( rva -- addr )
41 dup if
42 elf-base-rva - elf-target-memory +
43 endif
46 : real->tc ( addr -- rva )
47 dup if
48 elf-target-memory - elf-base-rva +
49 endif
52 : curr-code-size ( -- size )
53 elf-current-pc elf-base-rva -