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-11-04 20:19:15 -05:00
|
|
|
USING: alien compiler-backend generic hashtables kernel lists
|
|
|
|
math memory namespaces ;
|
2004-09-06 22:39:12 -04:00
|
|
|
|
2004-12-25 02:55:03 -05:00
|
|
|
: compiled-header HEX: 01c3babe ; inline
|
2004-09-06 22:39:12 -04:00
|
|
|
|
2005-03-28 23:45:13 -05:00
|
|
|
: compiled-byte ( a -- n )
|
2005-09-05 03:06:47 -04:00
|
|
|
f swap alien-signed-1 ; inline
|
2005-03-28 23:45:13 -05:00
|
|
|
: set-compiled-byte ( n a -- )
|
2005-09-05 03:06:47 -04:00
|
|
|
f swap set-alien-signed-1 ; inline
|
2005-03-28 23:45:13 -05:00
|
|
|
: compiled-cell ( a -- n )
|
2005-09-05 03:06:47 -04:00
|
|
|
f swap alien-signed-cell ; inline
|
2005-03-28 23:45:13 -05:00
|
|
|
: set-compiled-cell ( n a -- )
|
2005-09-05 03:06:47 -04:00
|
|
|
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 -- )
|
2004-12-25 02:55:03 -05:00
|
|
|
compiled-offset cell 2 * 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# )
|
|
|
|
address
|
|
|
|
literal-top set-compiled-cell
|
|
|
|
literal-top dup cell + set-literal-top ;
|
|
|
|
|
2004-09-06 22:39:12 -04:00
|
|
|
: compile-byte ( n -- )
|
|
|
|
compiled-offset set-compiled-byte
|
2005-09-16 22:47:28 -04:00
|
|
|
compiled-offset 1+ set-compiled-offset ; inline
|
2004-09-06 22:39:12 -04:00
|
|
|
|
|
|
|
: compile-cell ( n -- )
|
|
|
|
compiled-offset set-compiled-cell
|
2004-12-24 02:52:02 -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 )
|
|
|
|
compiled-header compile-cell
|
|
|
|
compiled-offset 0 compile-cell
|
|
|
|
compiled-offset 0 compile-cell ;
|
|
|
|
|
2005-03-20 19:05:57 -05:00
|
|
|
: w>h/h dup -16 shift HEX: ffff bitand >r HEX: ffff bitand r> ;
|