~vdupras/duskos

ref: 0c986dd34840500ff1f85d44cf5ac3274cbead69 duskos/fs/xcomp/tools.fs -rw-r--r-- 839 bytes
0c986dd3Virgil Dupras drv/pc/ich: add PCI fields specific to the ICHn family 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
\ Tools for cross-compiling binaries
\ In Dusk, we don't support cross-compiling Forth. It's too hairy. Here, we're
\ only talking about cross-compiling assembler code, with, optionally, a Forth
\ dict in it.

?f<< /lib/xdict.fs
?f<< /asm/label.fs \ org and binstart are there

newxdict xbindict

: xoffset binstart org - ;
: xcode word xbindict xentry ;

\ Usage: xwordlbl foo call, "foo" being a word name in xbindict
: xwordlbl ( "name" -- pc ) xbindict x' xoffset + ;

\ Traverse xdict and change all its prev field values so that they are related
\ to current org+binstart. Once this is done, the xdict can't be traversed
\ anymore and becomes opaque binary contents.
: orgifydict ( xdict -- )
  @ begin ( a )
    ?dup while ( a )
    5 - dup @ dup ( 'prev prev prev )
    xoffset + ( 'prev oldprev newprev ) rot ! ( prev ) repeat ;