![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

I have redefined C@ and C! to use @ and ! (below). Now to track down the
assembly instructions that do byte accesses ( B. ). The optimizer uses many
of them, so it needs to be turned off, but it is not readily apparent how to
turn off optimizing for the kernel too... commenting out include opt.f
altogether.
: C@ ( addr -- c ) \ Use @ to get c from addr, Big
Endian
DUP [ %11 INVERT ] LITERAL AND \ get c's cell-aligned address
@ ( a x0 ) \ fetch c's cell
SWAP %11 AND ( x0 n ) \ get c's byte offset
NEGATE 3 LSHIFT #24 + ( x0 y ) \ get c's source LSBit number (y =
-8x + 24, x is addr[1..0]); 3 LSHIFT is 8 * (multiply isn't defined)
RSHIFT ( x0' ) \ shift c into LSByte
$FF AND ( c ) \ strip x[31..8]
;
: C! ( c addr -- ) \ Use @ and ! to put c at addr, Big
Endian
SWAP $FF AND SWAP \ strip c[31..8]
DUP [ %11 INVERT ] LITERAL AND ( a0 ) \ get c's cell-aligned address
DUP @ ( c' a a0 x0 ) \ fetch cell data at c's destination
2SWAP %11 AND ( a0 x0 c' n ) \ get c's byte offset
NEGATE 3 LSHIFT #24 + ( a0 x0 c' y ) \ get c's destination LSBit number
(y = -8x + 24, x is addr[1..0]); 3 LSHIFT is 8 * (multiply isn't defined)
TUCK LSHIFT ( a0 x0 y x1 ) \ shift c into the byte position of
the cell-aligned address
-ROT $FF ( a0 x1 x0 y m )
SWAP LSHIFT INVERT AND ( a0 x1 x0' ) \ clear c's byte in destination cell
data
OR SWAP ! \ store c's cell
;
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Dec 16 2004 - 08:35:37 PST
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:50 PST