2005-01-17 19:55:18 -05:00
|
|
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
2005-03-15 22:23:52 -05:00
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-01-06 21:42:07 -05:00
|
|
|
IN: assembler
|
2005-12-02 02:25:44 -05:00
|
|
|
USING: alien generic hashtables kernel kernel-internals lists
|
2005-11-04 20:19:15 -05:00
|
|
|
math memory namespaces ;
|
2004-09-06 22:39:12 -04:00
|
|
|
|
2005-12-11 15:14:41 -05:00
|
|
|
: compiled-base 18 getenv ; inline
|
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
: compiled-header HEX: 01c3babe ; inline
|
2004-09-06 22:39:12 -04:00
|
|
|
|
2005-12-04 02:30:19 -05:00
|
|
|
: set-compiled-1 ( n a -- ) f swap set-alien-signed-1 ; inline
|
|
|
|
: set-compiled-4 ( n a -- ) f swap set-alien-signed-4 ; inline
|
|
|
|
: compiled-cell ( a -- n ) f swap alien-signed-cell ; inline
|
|
|
|
: set-compiled-cell ( n a -- ) f swap set-alien-signed-cell ; inline
|
2004-12-24 02:52:02 -05:00
|
|
|
|
2004-09-11 15:26:24 -04:00
|
|
|
: compile-aligned ( n -- )
|
2005-12-02 02:25:44 -05:00
|
|
|
compiled-offset 8 align set-compiled-offset ; inline
|
2004-09-11 15:26:24 -04:00
|
|
|
|
2005-08-22 02:06:32 -04:00
|
|
|
: add-literal ( obj -- lit# )
|
2005-12-04 22:29:55 -05:00
|
|
|
address literal-top [ set-compiled-cell ] keep
|
2006-01-26 23:01:14 -05:00
|
|
|
dup cell + set-literal-top ;
|
2005-08-22 02:06:32 -04:00
|
|
|
|
2005-12-04 02:30:19 -05:00
|
|
|
: assemble-1 ( n -- )
|
|
|
|
compiled-offset set-compiled-1
|
2005-09-16 22:47:28 -04:00
|
|
|
compiled-offset 1+ set-compiled-offset ; inline
|
2004-09-06 22:39:12 -04:00
|
|
|
|
2005-12-04 02:30:19 -05:00
|
|
|
: assemble-4 ( n -- )
|
|
|
|
compiled-offset set-compiled-4
|
|
|
|
compiled-offset 4 + set-compiled-offset ; inline
|
|
|
|
|
|
|
|
: assemble-cell ( n -- )
|
2004-09-06 22:39:12 -04:00
|
|
|
compiled-offset set-compiled-cell
|
2006-01-26 23:01:14 -05:00
|
|
|
compiled-offset cell + set-compiled-offset ; inline
|
2004-12-25 02:55:03 -05:00
|
|
|
|
|
|
|
: begin-assembly ( -- code-len-fixup reloc-len-fixup )
|
2005-12-04 02:30:19 -05:00
|
|
|
compiled-header assemble-cell
|
|
|
|
compiled-offset 0 assemble-cell
|
|
|
|
compiled-offset 0 assemble-cell ;
|
2004-12-25 02:55:03 -05:00
|
|
|
|
2005-03-20 19:05:57 -05:00
|
|
|
: w>h/h dup -16 shift HEX: ffff bitand >r HEX: ffff bitand r> ;
|