Reference

PA/1

Author

Pierre Abbat (phma@trellis.net)

Problem

In some existing Forths, words W@ and W! handle 16-bit quantities on a 32-bit machine. 16-bit Forths, however, do not have these words. Besides, W@ and W! use the same byte order as the machine, which may be different from the order defined by the file or protocol specification.

Proposal

@16B core-ext ( addr -- n )
The 16-bit quantity at addr is fetched with its MSB at the lower address. It is sign-extended if the cell width is greater than 16 bits.

@16L core-ext ( addr -- n )
The 16-bit quantity at addr is fetched with its LSB at the lower address. It is sign-extended if the cell width is greater than 16 bits.

U@16B core-ext ( addr -- n )
The 16-bit quantity at addr is fetched with its MSB at the lower address. It is zero-filled if the cell width is greater than 16 bits.

U@16L core-ext ( addr -- n )
The 16-bit quantity at addr is fetched with its LSB at the lower address. It is zero-filled if the cell width is greater than 16 bits.

!16B core-ext ( n addr -- )
The 16-bit quantity is stored at addr with its MSB at the lower address. The high-order bits are discarded if the cell width is greater than 16 bits.

!16L core-ext ( n addr -- )
The 16-bit quantity is stored at addr with its LSB at the lower address. The high-order bits are discarded if the cell width is greater than 16 bits.


@32B core-ext ( addr -- n )
The 32-bit quantity at addr is fetched with its MSB at the lower address. It is sign-extended if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

@32L core-ext ( addr -- n )
The 32-bit quantity at addr is fetched with its LSB at the lower address. It is sign-extended if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

2@32B double-ext ( addr -- d )
The 32-bit quantity at addr is fetched with its MSB at the lower address.

2@32L double-ext ( addr -- d )
The 32-bit quantity at addr is fetched with its LSB at the lower address.

U@32B core-ext ( addr -- n )
The 32-bit quantity at addr is fetched with its MSB at the lower address. It is zero-filled if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

U@32L core-ext ( addr -- n )
The 32-bit quantity at addr is fetched with its LSB at the lower address. It is zero-filled if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

U2@32B double-ext ( addr -- d )
The 32-bit quantity at addr is fetched with its MSB at the lower address.

U2@32L double-ext ( addr -- d )
The 32-bit quantity at addr is fetched with its LSB at the lower address.

!32B core-ext ( n addr -- )
The 32-bit quantity is stored at addr with its MSB at the lower address. The high-order bits are discarded if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

!32L core-ext ( n addr -- )
The 32-bit quantity is stored at addr with its LSB at the lower address. The high-order bits are discarded if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

2!32B double-ext ( d addr -- )
The 32-bit quantity is stored at addr with its MSB at the lower address.

2!32L double-ext ( d addr -- )
The 32-bit quantity is stored at addr with its LSB at the lower address.


@64B core-ext ( addr -- n )
The 64-bit quantity at addr is fetched with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

@64L core-ext ( addr -- n )
The 64-bit quantity at addr is fetched with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

2@64B double-ext ( addr -- d )
The 64-bit quantity at addr is fetched with its MSB at the lower address. It is sign-extended if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

2@64L double-ext ( addr -- d )
The 64-bit quantity at addr is fetched with its LSB at the lower address. It is sign-extended if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

U@64B core-ext ( addr -- n )
The 64-bit quantity at addr is fetched with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

U@64L core-ext ( addr -- n )
The 64-bit quantity at addr is fetched with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

U2@64B double-ext ( addr -- d )
The 64-bit quantity at addr is fetched with its MSB at the lower address. It is zero-filled if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

U2@64L double-ext ( addr -- d )
The 64-bit quantity at addr is fetched with its LSB at the lower address. It is zero-filled if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

!64B core-ext ( n addr -- )
The 64-bit quantity is stored at addr with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

!64L core-ext ( n addr -- )
The 64-bit quantity is stored at addr with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

2!64B double-ext ( d addr -- )
The 64-bit quantity is stored at addr with its MSB at the lower address. The high-order bits are discarded if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.

2!64L double-ext ( d addr -- )
The 64-bit quantity is stored at addr with its LSB at the lower address. The high-order bits are discarded if the cell width is greater than 32 bits. If the cell width is less than 32 bits, this word, if defined, shall cause a compiler error.


2@128B double-ext ( addr -- d )
The 128-bit quantity at addr is fetched with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

2@128L double-ext ( addr -- d )
The 128-bit quantity at addr is fetched with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

U2@128B double-ext ( addr -- d )
The 128-bit quantity at addr is fetched with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

U2@128L double-ext ( addr -- d )
The 128-bit quantity at addr is fetched with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

2!128B double-ext ( d addr -- )
The 128-bit quantity is stored at addr with its MSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

2!128L double-ext ( d addr -- )
The 128-bit quantity is stored at addr with its LSB at the lower address. If the cell width is less than 64 bits, this word, if defined, shall cause a compiler error.

Typical Use

These words are intended for manipulating fields in files and protocols that are defined to be a certain number of bytes in a certain order. This will make programs handling such data more portable.

Remarks

none.

Experience

none.

Comments

none.


[ Home ]